这是接口:
export interface Doctor {
lastName: string;
firstName: string;
format: string;
inami: string;
_id: string;
brusafe: {
login: string;
};
}
export interface DoctorList {
doctors: Array <{
id: string;
gp: boolean;
}>;
}
这是我的功能:
addNewDoctor(newDoctor: Doctor) {
console.log(newDoctor);
this.linkedDoctorShort.push({
id: newDoctor._id,
gp: false,
});
this.doctorLinked.push(newDoctor);
this.onSave();
}
这是HTML:
<div class="doctorlist">
<a (click)="addNewDoctor(newDoctor)">add</a>
<ul *ngFor="let doctor of doctorLinked; let d = index" >
<li> {{doctor.lastName}} {{linkedDoctorShort[d].gp}}<a
(click)="setAsGP(ind,isGP)"><i class="material-icons">
assignment_ind
</i></a><a (click)="deleteDoctor(doctor.lastName)"> <i
class="material-icons">
delete
</i></a></li>
</ul>
</div>
当我单击链接“添加”时,我试图在列表中添加医生,但提示“无法读取未定义的属性'_id'”