简体   繁体   中英

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

constructor(public 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.

You need to use pipe to add operators on the observable flow, try:

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;
  });
}));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM