[英]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.