Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/33.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
angularfire2获取子引用_Angular_Firebase_Ionic2_Angularfire2 - Fatal编程技术网

angularfire2获取子引用

angularfire2获取子引用,angular,firebase,ionic2,angularfire2,Angular,Firebase,Ionic2,Angularfire2,我有一个像这样的firebase数据库 如何获取阶段和地点的项目?我的目标是编写一个函数GetSelectOptions key:string,它返回一个列表,用于显示所提供键的选择选项。我希望通过仅从firebase获取select选项,然后在函数中返回子集,将数据库查询减少为1。到目前为止,我已经: this.selectOptions = af.database.list('/select-options'); 返回的selectOptions为 这是一种可能对您有所帮助的解决方法,但

我有一个像这样的firebase数据库

如何获取阶段和地点的项目?我的目标是编写一个函数GetSelectOptions key:string,它返回一个列表,用于显示所提供键的选择选项。我希望通过仅从firebase获取select选项,然后在函数中返回子集,将数据库查询减少为1。到目前为止,我已经:

this.selectOptions = af.database.list('/select-options');
返回的selectOptions为

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

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.
          }
     }
   }
});

在“选择选项”中,除了这两个对象之外,还有其他对象吗?是的,还有很多其他对象。这只是为了举例说明。我想我真的不知道如何使用可观性我认为这与可观性无关。angularfire返回数据的可观察值。但是,没有关系。我认为这不能在一个数据库调用中完成。您可能需要进行两次数据库调用。如果可能的话,重新定义你的数据模型,在一次调用中就可以做到这一点。但是所有的日期都已经包含在返回的observable中了。我只需要对其进行过滤,并将其以angulars ngFor可以理解的形式放入。那么您在获取对象选择选项中的所有数据时没有任何问题?