I am trying to fetch the data which is stored in my firebase structure .The data is stored according to the date.
Now I want to display the same in a table in the data wise manner,like the oldest one first and latest one last.
This is my firebase structure-
This is my html file-
<ion-content padding>
<ion-row class="row-header">
<ion-col>Date</ion-col>
<ion-col>Num</ion-col>
<ion-col>Debit (-)</ion-col>
<ion-col>Credit (+)</ion-col>
<!-- <ion-col>Balance</ion-col>-->
</ion-row>
<br><br>
<ion-row *ngFor='let currentEvent of accountlist' >
<ion-col>{{ currentEvent?.date}} </ion-col>
<ion-col>{{ currentEvent?.num}} </ion-col>
<ion-col>{{ currentEvent?.withdrawal }} </ion-col>
<ion-col>{{ currentEvent?.deposit }} </ion-col>
</ion-row>
</ion-content>
Ts- file-
export class SummaryPage {
currentEvent:any;
currentDate:any;
constructor(public navCtrl: NavController, public CheckbookAccountsProvider:CheckbookAccountsProvider, public navParams: NavParams) {
}
ionViewDidEnter(){
this.CheckbookAccountsProvider.getAccountcheckbook(this.navParams.get('eventId'),this.navParams.get('date'))
.on('value', eventSnapshot => {
this.currentEvent = eventSnapshot.val();
});
}
Provider-
getAccountcheckbook(accountId:string,date:Date):firebase.database.Reference
{
return this.userProfileRef.child(`${accountId}`).child('Journal details').child(`${date}`);
}
addJournal(date: Date, num: string, details:string,withdrawal: number,deposit:number,accountId,bank:string,balance:number):firebase.Promise<any> {
return this.userProfileRef.child(accountId).child('Journal details').child(date.toString()).set({
date: new Date(date).toString(),
num: num,
details:details,
withdrawal:withdrawal,
deposit:deposit,
bank:bank,
});
}
I am unable to get any item and table is blank.
Please provide some pointers.