【发布时间】:2017-11-05 09:38:05
【问题描述】:
假设我们有一个数据库:
Recipes
recipe_key(some uniq key generated when data pushed)
ingredients:pepper
如何使用 recipe_key 检索辣椒值?我检查了 angularfire2 的文档,它说使用快照更改,但是使用此代码我只能获得“食谱”。我想我需要再往下一层?
constructor(afDb: AngularFireDatabase) {
afDb.object('/recipes/').snapshotChanges().map(action => {
const $key = action.payload.key;
const data = { $key, ...action.payload.val() };
return data;
}).subscribe(item => console.log(item.$key));
}
【问题讨论】:
-
什么是'items/1'?
-
哦,对不起,我直接从文档中获取了该代码,它应该是食谱
标签: firebase firebase-realtime-database angularfire2