我有一个为我的 Article 模型返回 $resource 的工厂:
angular.module('ADI.Resources').factory("Articles", ['$resource', function($resource) {
return $resource('/api/v1/article/:articleId', {
articleId: '@_id',
_shop: window.user._shop
}, {
update: {
method: 'PUT'
}
});
}]);
GET
,POST
并且DELETE
运行良好,但不是更新 (PUT)。这是我使用的代码:
Articles.update({articleId: '300000000000000000000001'}, function(article){
console.log(article);
});
它提出了这个要求:
PUT http://localhost:3000/api/v1/article?_shop=100000000000000000000001
代替:
PUT http://localhost:3000/api/v1/article/300000000000000000000001?_shop=100000000000000000000001
知道为什么在进行更新时没有填充 :articleId 参数吗?谢谢!