【发布时间】:2018-06-27 17:56:33
【问题描述】:
getSpecificData(par) {
return this.afd.list('products/products', ref => ref.orderByChild('par').equalTo(par)).valueChanges();
}
在我的组件中,我有这个:
export class Product {
name: string;
price: string;
quantity: string;
}
ionViewDidLoad() {
let aux =this.readData();
console.log('Products', aux);
}
readData() {
return this.firebaseService.getSpecificData(this.par).subscribe(
items => {
this.data = items,
console.log('Data from Firebase ', this.data)
}
);
}
“console.log('Data from Firebase ', this.data)” 打印数据正确,但“console.log('Products', aux);”让我不确定。
我做错了什么?
我的目标是迭代数据数组并将每个项目转换为产品类型的对象。
问候,
【问题讨论】:
标签: json typescript ionic-framework