angularfire2得到孩子参考

时间:2017-02-16 11:46:36

标签: angular firebase ionic2 angularfire2

我有这样的firebase数据库 enter image description here

如何获取phaseplaces的项目?我的目标是编写一个函数getSelectOptions(key:string),它返回一个列表,用于显示所提供密钥的选择选项。我想通过从firebase获取select-options然后在函数内返回子集来将数据库查询减少到1。我到目前为止:

this.selectOptions = af.database.list('/select-options');

返回的selectOptions是 enter image description here

1 个答案:

答案 0 :(得分:1)

这是一种可能对您有所帮助的解决方法,但必须有另一种方法:

this.selectOptions.subscribe(items=> {
   for(let options of items){
     for (var property in options) {
          if (options.hasOwnProperty(property) && property.indexOf("$")!=0){
            console.log(options[property]); //Should contain an object phase.
          }
     }
   }
});