I want every object under each date under an expense category, in the Firebase Database.
In Firebase:
- expenses
- food
- 07-11-2016 //"I want every object in here"
+ -KX7Aju4_G6i6pcNoBzj
In my view I've tried:
<div *ngFor="let date of food | async">
<ion-item-divider sticky>
{{date.$key}}
</ion-item-divider>
<div *ngFor="let item of date"> //This don't seem to work
<ion-item>
<h3>{{item.title}}</h3>
<p>
{{item.amount}} Kr —
kl. {{item.time}}
</p>
</ion-item>
</div>
</div>
FIREBASE WARNING: Exception was thrown by user callback. Error: Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays.
Clearly it gives me the date as an object, not an array.
I've also tried retrieving the values in JSON, but iterating the JSON object with *ngFor (with out the pipe async) also gives me a bunch of problems.
/* Returns a Firebase list object as a JSON object */
getAsJSON(firebaseList: any){
firebaseList
.map(obj => obj.map(obj => {
return obj;
}));
}
I'm trying to iterate the firebase list object "food".
this.food = af.database.list('/expenses/food');
OR
this.food_json = getAsJSON(this.food);
I've read and tried a bunch, but I can't seem to find the right solution.