javascript - 单击链接时如何将数据库中的项目添加到列表中?
问题描述
这是接口:
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'”
解决方案
推荐阅读
- ldap - 将本地组添加到 Fedora 上的 ldap 登录用户
- pandas - ImportError:无法从“熊猫”导入名称“标志”
- swift - 如何在 SwiftUI 中通过动画使背景消失?
- jenkins - 使用 Jenkins 从 Gitlab 管理 K8s 集群
- javascript - 无法读取未定义的属性“main_text_matched_substrings”
- python - 保持消息计数离线 discord.py
- r - R 中的三元图 - ggter 3.3.0 与旧版本
- java - log4j2 滚动文件附加程序中的文件名问题
- c# - 是否可以在 lambda 函数中创建动态场?
- javascript - Google Translate js 在 ie 中不起作用,但在 chrom、edge 和 firefox 中起作用