[英]import 'rxjs/add/operator/map'; using AngularFirestore, AngularFirestoreCollection, AngularFirestoreDocument
constructor(public afs: AngularFirestore) { this.itemsCollection = this.afs.collection('items', ref => ref.orderBy('title', 'asc'));构造函数(公共 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 is not recognized. } map 无法识别。
You need to use pipe
to add operators on the observable flow, try:您需要使用
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.