我有一个资源工厂,带有一个名为 update 的 POST 方法:
PnrApp.factory('Feed', function ($resource, $cacheFactory, $q, $rootScope) {
var Feed = $resource('api/feeds/:post', { post: 'post' }, {
get: { method:'GET' },
update: { method: 'POST' }
});
return Feed;
});
当我调用该方法时,它会按预期将数据发布到服务器:
$rootScope.toggleStar = function (post, feedname) {
var updated = Feed.update(post);
this.child.StarId = updated.StarId;
}
服务器返回正确的值(注意这个 json 中的 StarId):
{"Name":"13 Ways to Act Like A Business Owner","ItemDate":"June 6, 2013","Url":"/post/13-Ways-to-Act-Like-A-Business-Owner-Stop-Acting-Like-an-Advisor-All-the-Time-(6-min-03-sec).aspx","StarImg":"bulletstar-on.png","StarId":1324,"StarDate":"0001-01-01T00:00:00","FeedCount":0,"FeedId":19,"SourceIcon":null,"IsBroken":false,"ItemId":"01"}
但是,如果您查看 var updated 对 StarId 的返回值,请注意它是“0”:
有人可以解释为什么会这样,以及在这种情况下我如何获得返回值?