簡體   English   中英

導入'rxjs/add/operator/map'; 使用 AngularFirestore、AngularFirestoreCollection、AngularFirestoreDocument

[英]import 'rxjs/add/operator/map'; using AngularFirestore, AngularFirestoreCollection, AngularFirestoreDocument

構造函數(公共 afs:AngularFirestore){ this.itemsCollection = this.afs.collection('items', ref => ref.orderBy('title', 'asc'));

this.items = this.itemsCollection.snapshotChanges().map(changes => {
  return changes.map(a => {
    const data = a.payload.doc.data() as Item;
    data.id = a.payload.doc.id;
    return data;
  });
});

} map 無法識別。

您需要使用pipe在可觀察流上添加運算符,嘗試:

this.items = this.itemsCollection.snapshotChanges().pipe(map(changes => {
  return changes.map(a => {
    const data = a.payload.doc.data() as Item;
    data.id = a.payload.doc.id;
    return data;
  });
}));

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM