0
下面的代碼應該從firebase獲取對象,array
。
this.item2 = this.af.object('/profiles/' + this.username + '/followers');
this.subscription5 = this.item2.subscribe(item => {
console.log(JSON.stringify(item) + " followers number 98989899889");
if(Object.keys(item)[0] == '$value') {
this.followers = 0;
}
else {
this.followers = item.length;
}
})
這是我的火力數據庫的結構:
"profiles" : {
"Jencuts" : {
"address" : "34 school st dedham ma",
"bio" : "I love cuts. Cuts are my jam i am jencuts who are you?",
"email" : "[email protected]",
"followers" : [ {
"Jencuts" : "gxPYJNXcOagJr7gxNzPLtUY9aZF2"
} ],
"password" : "Kjhvjjjjbcv",
"price" : "$$$$",
"rating" : {
"five" : 0,
"four" : 0,
"one" : 0,
"three" : 0,
"two" : 0
},
"username" : "Jencuts"
},
....
Jencuts
是用戶名(this.username
)。
它應該返回followers
數組,而不是說它沒有找到任何內容並返回{$value:null}
。