我正在使用此服务从Firebase获取数据,但是当我在角度7中更改路由时,我必须重新加载页面以使数据出现,知道我有什么问题?
constructor(private afs: AngularFirestore) {
this.itemsCollection = afs.collection<Item>('items');
this.items = this.itemsCollection.snapshotChanges().pipe(
map(actions => actions.map(a => {
const data = a.payload.doc.data() as Item;
const id = a.payload.doc.id;
return { id, ...data };
}))
);
}