Javascript 如何准备firebase db集合中的键和值
我在firebase中有以下db结构。我想检索此集合并在视图中使用ngFor显示。不过,我希望每个对象的读取键(firebase在使用push方法时生成)在以后使用 我正在检索这样的数据Javascript 如何准备firebase db集合中的键和值,javascript,angular,firebase,firebase-realtime-database,Javascript,Angular,Firebase,Firebase Realtime Database,我在firebase中有以下db结构。我想检索此集合并在视图中使用ngFor显示。不过,我希望每个对象的读取键(firebase在使用push方法时生成)在以后使用 我正在检索这样的数据 this.dbref = firebase.database().ref('My top node here'); this.dbref.once('value').then(snapshot => this.myProperty = snapshot.val()); 如果我记录myProperty,
this.dbref = firebase.database().ref('My top node here');
this.dbref.once('value').then(snapshot => this.myProperty = snapshot.val());
如果我记录myProperty,我可以看到对象集合以及类似的键,但我不知道如何读取与每个对象关联的键。有人能帮忙吗
我想您正在寻找:
this.dbref = firebase.database().ref('My top node here');
this.dbref.once('value').then(snapshot => {
this.myProperty = snapshot.val();
snapshot.forEach(child => {
console.log(child.key, child.val());
});
})
我想你在寻找:
this.dbref = firebase.database().ref('My top node here');
this.dbref.once('value').then(snapshot => {
this.myProperty = snapshot.val();
snapshot.forEach(child => {
console.log(child.key, child.val());
});
})