【发布时间】:2017-05-09 20:25:40
【问题描述】:
对不起我的英语,我有这个可观察的:
this.productos = af.database.list('/productos', {
query: {
orderByChild: 'categoria',
equalTo: this.catnombre
}
});
我需要从这里提取所有 id 并设置在一个数组中,但我不知道如何,谢谢。
编辑:
我可以提取id但我使用de key,现在我需要提取其他数据,但是snapshot.val,不起作用。
this.productos = af.database.list('/productos/', {
query: {
orderByChild: 'categoria',
equalTo: this.catnombre
}, preserveSnapshot:true
});
this.productos.subscribe(snapshot => {
snapshot.forEach(snapshot => {
console.log(snapshot.key);
this.idproductos.push(snapshot.key);
});
console.log(this.idproductos);
});
【问题讨论】:
标签: firebase ionic-framework firebase-realtime-database ionic2 angularfire2