在执行ngIf
时出错<li *ngFor="let patient of patients">
{{patient.id}}
</li>
我的组件如下所示:
private showAllPatients() {
this.patientService.getAll().subscribe(patients => { this.patients =
patients; });
}
来自api的响应如下:
{
"patientProfiles": [
{
"id": "159",
"firstName": "Anne",
"lastName": "Frank"
},
{
"id": "2",
"firstName": "Max ",
"lastName": "Start"
}]}
我认为这个问题是因为“patientProfiles”但是我怎样才能访问它?
答案 0 :(得分:2)
您需要访问 patients.patientProfiles
<li *ngFor="let patient of patients.patientProfiles">