我在 angularjs 的控制器中有这段代码
$scope.likeit = function(entry) {
entry.like = !entry.like;
var ret = VoteResource.save(entry);
console.log("Return Object")
console.log(ret)
console.log("======================================")
console.log("Return Like Property")
console.log(ret.like_count)
return ret
};
当我尝试在我的视图中触发此功能并在控制台中检查时,这是输出
Return Object
Resource {comment_count: 0, confess: "Hello world!!! kk", created_at: "2013-06-11T00:26:25Z", feeling_id: 0, hug_count: 0…}
comment_count: 0
confess: "Hello world!!! kk"
created_at: "2013-06-11T00:26:25Z"
feeling_id: 0
hug_count: 0
id: 1
like_count: 0
metoo_count: 0
updated_at: "2013-06-11T23:48:16Z"
user_id: null
__proto__: Resource
======================================
Return Like Property
1
我的问题为什么是 ret.like_count 返回 1。在第一个控制台日志中,like_count 的资源值为零 (0),但在 ret.like_count 输出中返回 1。为什么?那么如何访问资源中的 like_count 呢?