
I need to fetch data from firebase database. I am able to get data of “dueDate” through {{currentBill?.dueDate}} but don’t know how to get data of other items above it. Following is the code used to fetch data:
ionViewDidEnter(){
this.firebaseData.getBillDetail(this.navParams.get('billId'))
.on('value', snapshot => {
this.currentBill = snapshot.val();
this.currentBill.id = snapshot.key;
});
}
Kindle help
Well Im guessing the root id of the bills would be some sort of userId. To get the other bills you would get the data by the userid (KmthCJ10rBqHVIThiPN) and then parse the data on your side to get the dueDate for each bill.
Not sure what you are asking… I am getting dueDate. My worry is the data above it. I want to get data of child of currentBill
What I mean is why dont you pull your data with this id? Instead of pulling with the billId.

Misunderstood… Let me try that … But not sure how will it apply to all similar data?
Sorry I misundestood your data structure. Why dont you do a structure like this:
billId:
- extraItems:
- KnHNPuRsIU ...
- KnHNn7RprQ ...
- etc ...
- dueDate: " ... "
So you get bill details, and get the extra items by currentBill.extraItems.
Can’t do that. Data structure is good for me
I see, well the probelm is, the data you get when you fetch the bill details will be a json object. So the attribute names will be those unique child ids, which is a bit messy.
So lets say in this case it would be
this.currentBill['-KnHNPuRsIUSGbxN0jcz'];
So you would have to loop trough the JSON object and get all the data that has those unique IDs.
I tried all ways… Not working . Not sure why its so difficult to refer the child 
ionViewDidEnter(){
this.firebaseData.getBillDetail(this.navParams.get('billId'))
.on('value', snapshot => {
this.currentBill = snapshot.val();
this.currentBill.id = snapshot.key;
});
}
How can I refere each child… Can anyone suggest forEach function to capture the child IDs created… Further those ids can be looped to get items contained in these IDs
Well this is a standard way to loop trough json object attributes:
for (let key in this.currentBill) {
console.log(key + " -> " + this.currentBill[key]);
}
Thanks. It does work. Also back ticks in providers (or others) to route with ${billId} works. Thanks