我$rootScope.globals
对象是以下:
{
currentUser: {
id: "56309272279724c02b319392"
name: "Özgür Adem"
picture: "http://www.gravatar.com/avatar/c4ca4238a0b23452sdcc503a6f76829z? d=retro"
ptoken: "mFFa9l25HbB4fbh7"
role: Object
},
unread: 0
}
当我打印到控制台这样console.log($rootScope.globals)
或console.log($rootScope.globals.currentUser)
一切良好。
但是当我尝试打印console.log($rootScope.globals.unread)
,输出为undefined
。
为什么?我认为如果属性值等于undefined
,则在其他输出中不应该看作0。我错了吗?
这里有什么问题?
我硝基甲苯发现任何问题。它应该工作 – Sajeetharan
@Sajeetharan我想是这样,但不工作 –
@Furkan,你看到的价值邻为'unread'打印'的console.log($ rootScope.globals)时' – M22an