我有这样的API调用
组件:
this._newTripApi.getData().subscribe(selected => {
this.selectedSettings = selected;
this.isLoading = false;
})
服务:
public getData(): Observable<any>
{
return this._api.get(`instances/${this._config.getData().user.instance._id}?fields=newTripSettings`)
.map(res => res.data.newTripSettings);
}
当我使用res.json()时,它说json不是函数,JSON响应如下所示,我需要在支持的html中显示所有newtripSettings对象,但它说: 找不到类型为“对象”的其他支持对象“ [对象对象]”。 NgFor仅支持绑定到Iterables,例如数组。解决方案?
{
"data": {
"_id": "5aaab927c756c86c15d3b1dc",
"newTripSettings": {
"betweenSites": {
"enabled": true,
"consultation": {
"enabled": true
},
"radiotherapy": {
"enabled": true
},
"chemotherapy": {
"enabled": true
},
"dialysis": {
"enabled": true
},
"coronarography": {
"enabled": true
},
"scan": {
"enabled": true
},
"transfer": {
"enabled": true
},
"urgentPatientStop": {
"enabled": true
},
"urgentOther": {
"enabled": true
},
"otherPaidByHospital": {
"enabled": true
},
"otherPaidByPatient": {
"enabled": true
},
"fromSite": {
"enabled": true
"discharge": {
"enabled": true
},
"consultation": {
"enabled": true
},
"radiotherapy": {
"enabled": true
},
"chemotherapy": {
"enabled": true
},
"dialysis": {
"enabled": true
},
"coronarography": {
"enabled": true
},
"scan": {
"enabled": true
},
"urgentPatientStop": {
"enabled": true
},
"urgentOther": {
"enabled": true
},
"otherPaidByHospital": {
"enabled": true
},
"otherPaidByPatient": {
"enabled": true
}
},
"toSite": {
"enabled": true,
"hospitalisation": {
"enabled": true
},
"consultation": {
"enabled": true
},
"radiotherapy": {
"enabled": true
},
"chemotherapy": {
"enabled": true
},
"dialysis": {
"enabled": true
},
"coronarography": {
"enabled": true
},
"scan": {
"enabled": true
},
"otherPaidByHospital": {
"enabled": true
},
"otherPaidByPatient": {
"enabled": true
}
},
"other": {
"enabled": true,
"discharge": {
"enabled": true
},
"hospitalisation": {
"enabled": true
},
"consultation": {
"enabled": true
},
"radiotherapy": {
"enabled": true
},
"chemotherapy": {
"enabled": true
},
"dialysis": {
"enabled": true
},
"coronarography": {
"enabled": true
},
"scan": {
"enabled": true
},
"otherPaidByPatient": {
"enabled": true
}
}
}
}
}