angular - 如何在保存到数据库之前编辑新添加对象的保存数据
问题描述
我有一个formarray,如果我编辑来自数据库中保存的数据的值,因为它的唯一ID为agentW9id,因此它会在该特定行中更新,但对于新添加的行,因为没有唯一ID ,如何在编辑时保存对该特定行的更改并在单击保存按钮时显示更改的值。
我在这里有工作演示: DEMO
TS:
saveW9Details(item) {
if(this.employee ) {
if(item.agentW9id.value) {
for(var i=0;i<this.employee.length;i++){
if(this.employee[i].agentW9id===item.agentW9id.value){
this.employee[i].taxId=item.taxId.value;
this.employee[i].businessType=item.businessType.value;
this.employee[i].signatureDate=item.signatureDate.value;
this.employee[i].agentW9id = item.agentW9id.value;
// updated=true;
this.temporaryControls.push(this.employee[i])
}
}
} else {
var temp={
taxId:item.taxId.value,
signatureDate:item.signatureDate.value,
businessType: item.businessType.value,
agentW9id:item.agentW9id.value,
businessName: item.businessName[0].value,
originalFileName:item.fileName.value?item.fileName.value.slice(12):''
}
if(this.employee) {
this.employee.push(temp);
this.temporaryControls.push(temp)
}
// this.getFormData.removeAt(item)
}
} else {
console.log(item,"dsds")
let temp={
taxId:item.taxId.value,
signatureDate:item.signatureDate.value,
businessType: item.businessType.value,
agentW9id:item.agentW9id.value,
businessName: item.businessName[0].value,
originalFileName:item.fileName.value?item.fileName.value.slice(12):''
};
this.temporaryControls.push(temp)
}
this.getFormData.removeAt(item);
}
}
解决方案
推荐阅读
- ant - 如何通过命令行选项将命令行选项传递给 java 编译器
蚂蚁任务使用 ? - git - 来自 Windows 10 主机的 Centos 7 devcontainer 中的 GPG 签名提交
- jquery - 固定页眉出现在不同页面的不同位置
- node.js - 如何使用 Google Closure Compiler 浏览您的 Node.js 库
- python - 有没有办法在 Kivy 弹出窗口中调整内容的大小
- r - 如何在R中的foreach()中更改数据框的某些列的长度
- google-cloud-platform - Google Compute Engine (GCE) 永久性磁盘 (PD) 快照是否具有崩溃一致性?
- node.js - (node:21) UnhandledPromiseRejectionWarning: error: no pg_hba.conf entry for host "0.0.0.0", user "abcdefghi", database abcdefg", SSL off
- flutter - 如何在 CalendarTimeline() 包中仅显示日期编号和名称?
- c# - 为什么布局组上实例化的最后一个元素显示为第一个且错误?