我有文档id,并尝试通过id获取文档数据:
export class MyComponent implements OnInit {
customerDoc: AngularFirestoreDocument<Customer>;
customer: Observable<Customer>;
constructor(private afs: AngularFirestore) {
const id = this.route.snapshot.paramMap.get('id');
this.customerDoc = afs.collection<Customer>('customers/'+id);
this.customer = this.customerDoc.snapshotChanges();
}
}
但它不返回任何内容。
发布于 2018-10-31 17:26:00
尝尝这个,
this.afs.collection<Customer>('customers/'+id).snapshotChanges().map(actions=>{
return actions.map(b=>{
const data = b.payload.doc.data();
const id = b.payload.doc.id;
return {uid:id,...data}
})
});
https://stackoverflow.com/questions/53079953
复制相似问题