通过userId从Firebase数据库获取数据

时间:2019-01-15 09:31:25

标签: firebase firebase-realtime-database

我正在尝试从数据库Firebase中获取数据,但是没有数据显示在列表项html中,因为我首先在数据库中推送了UserId

enter image description here

items: Observable<any[]>;
itemsRef: AngularFireList<any>;

  constructor(,public fire: AngularFireAuth,public db: AngularFireDatabase) 
    {
        this.itemsRef = db.list('report/');
        // Use snapshotChanges().map() to store the key
        this.items = this.itemsRef.snapshotChanges().pipe(
          map(changes => 
            changes.map(c => ({ key: c.payload.key, ...c.payload.val() }))
          )
        );


      }

您在这里看不到要显示在列表项中的数据

enter image description here

html

  <ion-list *ngFor="let item of items | async"> 
    <ion-item-sliding>
      <ion-item>
        <h2>{{item.title}}</h2>
        <p>{{item.name}}</p>
        <p>{{item.username}}</p>
        <p>{{item.dateadded}}</p>
    </ion-item>

      <ion-item-options side="right"> 
        <button ion-button color="danger" (click)="deletReport(item.key)">
          <ion-icon  ios="ios-trash" md="md-trash" item-end large></ion-icon>
        </button>
        <button ion-button color="primary" (click)="updatereport(item.key,item.name,item.title)">
          <ion-icon ios="ios-create" md="md-create"></ion-icon>
        </button>
      </ion-item-options>

    </ion-item-sliding>
  </ion-list>

0 个答案:

没有答案