getSpecificData(par) {
return this.afd.list('products/products', ref => ref.orderByChild('par').equalTo(par)).valueChanges();
}
In my components, i have this:
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)
}
);
}
The "console.log('Data from Firebase ', this.data)" is printing data right, but "console.log('Products', aux);" is getting me undefined.
What i am doing wrong?
My aim is to iterate the array of data and transform each item into an object of type product.
Regards,