编辑新添加的行并更新对该行的更改,而不是使用angular8中的formArray被动表单创建新项目

编辑新添加的行并更新对该行的更改,而不是使用angular8中的formArray被动表单创建新项目,angular,forms,angular-reactive-forms,reactive,reactive-forms,Angular,Forms,Angular Reactive Forms,Reactive,Reactive Forms,我有一个formArray,如果我创建了新项目并更新了该特定项目,而不是得到更新,它将被新添加,并且它必须发送到final,只保存上次更新的值,而不是为每次编辑新添加的项目创建新项目 演示: TS: savew9详细信息(项目){ this.addButtonDisable=false; 如果(本员工){ if(item.agentW9id.value){ 对于(var i=0;i)当您添加/更新时,您正在检查item.agentW9id.value,因此,如果您没有在那里输入任何内容,您将根

我有一个formArray,如果我创建了新项目并更新了该特定项目,而不是得到更新,它将被新添加,并且它必须发送到final,只保存上次更新的值,而不是为每次编辑新添加的项目创建新项目

演示:

TS:

savew9详细信息(项目){
this.addButtonDisable=false;
如果(本员工){
if(item.agentW9id.value){

对于(var i=0;i)当您添加/更新时,您正在检查item.agentW9id.value,因此,如果您没有在那里输入任何内容,您将根据您的回答插入新行。是的,我能够解决此问题,感谢您的回复
 saveW9Details(item) {
this.addButtonDisable = false;
        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]);
                this.getFormData.removeAt(i)
              }
           }
          } else {

            var temp={
              taxId:item.taxId.value,
              signatureDate:item.signatureDate.value,
              businessType: item.businessType.value,
              agentW9id:item.agentW9id.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);


        }