So basically, i have a ionic mobile application that retrieves data from Firebase.
this is the code for html that displays data which comes from travalList$ that is an observable.
<ion-list *ngFor="let item of travelList$ | async">
<ion-card (click)="itemTapped($event, item)" *ngIf="item.userId != currentUserId">
<ion-card-header>
<h4><b>{{item.firstname}} {{item.lastname}} ({{item.email}})</b></h4>
</ion-card-header>
<ion-card-content>
<h5>{{item.fromAddress}}</h5>
<p>at {{item.fromDate}}</p>
<h6>To</h6>
<h5>{{item.toAddress}}</h5>
<p>at {{item.toDate}} </p>
</ion-card-content>
</ion-card>
code for initializing items to be displayed. this is called at the constructor,so the getTravelList() retrieves data from firebase.
initializeItems(){
this.travelList$ = this.plsdala.getTravelList()
.snapshotChanges()
.map(
changes => {
return changes.map(c=>({
key: c.payload.key, ...c.payload.val()
})).slice().reverse();
console.log(this.travelList$); //to reverse order
});
}
i wanted to put the retrieved data in an array but how do i wait the observable? i need the array for search function.