【发布时间】:2017-11-11 16:46:10
【问题描述】:
我想使用navParams 获取一些数据,但它不工作,但如果我提供静态值,那么它工作。我不知道出了什么问题。这是我的代码不起作用并返回空
console.log(this.navParams.get('id')) // prints 10
const id = this.navParams.get('id');
this.categoryRef = this.db.list('/category', ref => ref.orderByChild('id').equalTo(id));
this.category = this.categoryRef.snapshotChanges().map(changes => {
return changes.map(c => ({ key: c.payload.key, ...c.payload.val() }));
});
如果我给出静态值,那么它就像
const id = 10;
this.categoryRef = this.db.list('/category', ref => ref.orderByChild('id').equalTo(id));
this.category = this.categoryRef.snapshotChanges().map(changes => {
return changes.map(c => ({ key: c.payload.key, ...c.payload.val() }));
});
【问题讨论】:
-
你在哪里调用这个方法?生命周期事件?
-
我在
ionViewDidLoad()和constructor都试过了
标签: firebase firebase-realtime-database ionic3 angularfire2