gc-http-factory

码农软件 · 软件分类 · AngularJS 扩展 · 2019-03-17 11:59:38

软件介绍

gc-http-factory 是一个 AngularJS 的扩展,提供更便利的 API 写法,例如常规我们定义一个 Service 的方法如下:

angular.app('app', []).factory('UsersService', function($http) {
  function findOne(id) {
    return $http.get('/api/users/' + id);
  };

  function findAll() {
    return $http.get('/api/users');
  };

  function create() {
    return $http.post('/api/users');
  };

  return {
    findOne: findOne,
    findAll: findAll,
    create: create
  };
});

而使用 gc-http-factory 后可以这样写:

angular.app('app', ['gc.httpFactory']).factory('UsersService', function(HttpFactory) {
  return HttpFactory.create({
    url: '/api/users/:id'
  }, {
    findOne: { method: 'GET' },
    findAll: { method: 'GET' },
    create: { method: 'POST' }
  });
});

调用方法:

UsersService.findAll(); //=> GET /api/users

UsersService.findOne({
  params: { id: 2 }
}); //=> GET /api/users/2

UsersService.create({
  data: { name: 'Jack' }
}); //=> POST /api/users with { name: 'Jack' } as data

本文地址:https://codercto.com/soft/d/1539.html

Real-Time Rendering, Third Edition

Real-Time Rendering, Third Edition

Tomas Akenine-Moller、Eric Haines、Naty Hoffman / A K Peters/CRC Press / 2008-7-25 / USD 102.95

Thoroughly revised, this third edition focuses on modern techniques used to generate synthetic three-dimensional images in a fraction of a second. With the advent or programmable shaders, a wide varie......一起来看看 《Real-Time Rendering, Third Edition》 这本书的介绍吧!

html转js在线工具
html转js在线工具

html转js在线工具

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试