如何从离子中的Firebase获取数据

时间:2019-06-18 15:10:46

标签: angular firebase ionic-framework

我尝试如图所示在应用程序中显示“总价值”

https://i.imgur.com/ZXxNLHJ.jpg

enter image description here 我尝试了这段代码,但没有与我合作:

itemsRef: AngularFireList<any>;
items: Observable<any[]>;
constructor(public db: AngularFireDatabase) {
  this.itemsRef = db.list("/shoopping-list/");
  this.items = this.itemsRef.snapshotChanges().pipe(
    map(changes => 
      changes.map(c => ({ key: c.payload.key, ...c.payload.val() }))
      ));
}

html

<ion-list style="padding-bottom: 0px;">
  <div>
    <ion-item-sliding *ngFor="let item of items.key | async">
      <ion-item>
        <div item-start>{{ item.Total }}</div>
      </ion-item>
    </ion-item-sliding>
  </div>
</ion-list>

0 个答案:

没有答案