资源:
angular.module('TicketService', ['ngResource'])
.factory('Ticket', ['$resource', function($resource){
var Ticket = $resource('/api/tickets/:id1/:action/:id2',
{
id1:'@id'
},
{
list: {
method: 'GET'
},
listByOwner: {
method: 'GET',
params: {
action:'owner',
id1:"@id"
}
}
update: {
method: 'PUT',
params:{}
}
});
return ticket;
}]);
询问:
$scope.userTickets = Ticket.listByOwner({
id : $rootScope.user.id
}, function(){
//success
}, function(response){});
结果:
Angularjs 构建了一个错误的 url,/api/tickets
但它应该是/api/tickets/2/owner
. 任何想法为什么?