【发布时间】:2014-08-04 09:47:59
【问题描述】:
我有一个解耦的 Restangular 服务,我想附加一个自定义方法。默认情况下,集合上返回的唯一方法似乎是 getList、one 和 post。我想做Locations.getLongLat()
我尝试将以下内容添加到我的服务中,但没有成功(该方法未绑定到对象),我只是得到undefined is not an object 作为响应。
angular.module('myApp')
.factory('Locations', function (Restangular) {
return Restangular.withConfig(function (RestangularConfigurer) {
RestangularConfigurer.addElementTransformer('api/v1/locations', true, function (location) {
location.addRestangularMethod('getLongLat', 'get', 'longlat');
return location;
});
}).service('api/v1/locations');
})
有人有什么想法吗?
【问题讨论】:
标签: angularjs angularjs-service restangular