'use strict';
angular.module('rmaServices', ['ngResource'])
.factory('rmaService', ['$resource',
function ($resource) {
return $resource(
'/RMAServerMav/webresources/com.pako.entity.rma/:id',
{},
{
delete: { method: 'DELETE', params: {id: '@rmaId'}},
update: { method: 'PUT', params: {id: '@rmaId'}},
//RMAServerMav/webresources/com.pako.entity.rma/0/3
findRange:{method: 'GET', params:{id:'@rmaId'/'@rmaId'}}
});
}]);
RMAServerMav/webresources/com.pako.entity.rma/0/3
这是使用 findRange REST 服务的正确方法。这个返回从 1 到 4 的 rmaID,但是我如何从 Controller 使用它以及服务中的正确语法是什么?
在 Controller 中我想使用类似的东西:
$scope.rmas = rmaService.findRange({id:'0'/'3'});
但这行不通。
最佳答案
您可以覆盖 url,阅读 $resource文档
url – {string} – action specific url override. The url templating is supported just like for the resource-level urls.
在资源声明中
findRange:{
url: '/RMAServerMav/webresources/com.pako.entity.rma/:id/:to',
method: 'GET',
params:{
id:'@id',
to: '@to'
}
}
在 Controller 中
$scope.rmas = rmaService.findRange({id:0, to: 3});
关于javascript - AngularJS $resource GET 中的多个参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30604693/