【发布时间】:2017-06-25 11:07:57
【问题描述】:
我想将snap.val() 分配给this.Productslike this.Products= snap.val();,但this.Products 在该范围内未定义。
Products: FirebaseListObservable<any>;
constructor(){
}
ionViewDidLoad(){
this.angularFire.database.list('/Products').$ref.orderByChild('uid')
.equalTo('NW1Kq4WB7ReUz2BNknYWML9nF133').on('child_added', function(snap){
console.log(snap.val().name);
//this.Products= snap.val();
});
}
我在返回 snap 时尝试了以下代码,但我收到了这条消息——No index defined for uid:
snap.forEach(SnapShot=>{
console.log(SnapShot.val().name)
我的 Firebase 数据库:
"Products" : {
"-Kbx0i-TFeTyRbNZAZ_8" : {
"category" : "1",
"detail" : "xxxxx details",
"name" : "xxxxx",
"uid" : "NW1Kq4WB7ReUz2BNknYWML9nF133"
}
请帮忙。谢谢。
【问题讨论】:
标签: angularjs firebase ionic-framework firebase-realtime-database ionic2