Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/373.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何准备firebase db集合中的键和值_Javascript_Angular_Firebase_Firebase Realtime Database - Fatal编程技术网

Javascript 如何准备firebase db集合中的键和值

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,

我在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();
  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());
  });
})