在尝试从Firestore访问子集合时,我在数据变量中拥有所有值,当我尝试打印值时,出现错误InvalidPipeArgument:'[object Object]'for pipe'AsyncPipe'
下面的代码段中的“数据”具有以下值
[
{
"_id": "5c21d780f82aa31334ab6506",
"billingHours": [
{
"_id": null,
"totalHours": 16
}
]
},
{
"_id": "5c21d780f82aa31334ab6507",
"billingHours": [
{
"_id": null,
"totalHours": 16
}
]
}
]
在我的html代码中,我尝试打印ID“游泳池”的值
data:{
"Kids Pool":
{"Chlorine":"Present","Color":"Nil","Turbidity":"Nil","pH":"Neutral"},
"Main Pool":
{"Chlorine":"Nil","Color":"Green","Turbidity":"Yes","pH":"7"},
"id":"Swimming Pool"}
this.dieselGeneratorCollections =
this.afs.collection('apartments/1001-
SJR Verity/Daily Readings');
this.posts = this.dieselGeneratorCollections.valueChanges();
this.dailyReadings =
this.dieselGeneratorCollections.snapshotChanges().pipe(
map(actions => {
return actions.map(a => {
const data = a.payload.doc.data() as any;
data.id = a.payload.doc.id;
console.log("data:"+JSON.stringify(data) );
return data;
});
}));
如何打印“ swimmingPool”的值