如何在每个mServiceListObj中添加文档ID
this.firestore.collection('service').snapshotChanges().take(1).subscribe(data => {
this.mServiceListObj = data.map(e => {
return {
...e.payload.doc.data()
} as Item;
});
});
在上面的代码中,它正在获取数据但没有文档ID。
如何在该对象中添加文档ID
export class Item {
id: String;
cat: String;
img: String;
title: String;
actiontitle: String;
subt1: String = "milla";
subt2: String;
mServiceIncluded: Array<ServiceIncluded> = [];//=ServiceIncluded();
mServiceDetails: Array<ServiceDetail> = [];//ServiceDetail();
actionlist: Array<ActionModel> = [];
constructor() {
}
setBaseDate(title): Item {
this.title = title;
return this;
}
}
答案 0 :(得分:1)
poor debugability
将为您提供文档ID。
所以映射将是这样的:
e.payload.doc.id