Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 从formArray中删除FormControl_Angular_Typescript_Angular Reactive Forms - Fatal编程技术网

Angular 从formArray中删除FormControl

Angular 从formArray中删除FormControl,angular,typescript,angular-reactive-forms,Angular,Typescript,Angular Reactive Forms,我已经创建了我的FormGroup,如下所示 this.GSTNForm = this.formbuilder.group({ gstRegistrationStatusId: new FormControl(''), reasonForNonApplicabilityofGST: new FormControl(''), isExemptGoods: new FormControl(false), goodServiceRemarks: new

我已经创建了我的FormGroup,如下所示

this.GSTNForm = this.formbuilder.group({
      gstRegistrationStatusId: new FormControl(''),
      reasonForNonApplicabilityofGST: new FormControl(''),
      isExemptGoods: new FormControl(false),
      goodServiceRemarks: new FormControl(''),
      gstandbankDetails: this.formbuilder.array([
        this.formbuilder.group({
          _id: new FormControl(''),
          sequenceNo: new FormControl(this.gstnSequenceValue),
          gstn: new FormControl(''),
          addressline1: new FormControl(''),
          addressLine2: new FormControl(''),
          stateCode: new FormControl(''),
          cityCode: new FormControl(''),
          countryCode: new FormControl(''),
          pinCode: new FormControl(''),
          accountHolderName: new FormControl(''),
          accountTypeId: new FormControl(''),
          bankName: new FormControl(''),
          branchName: new FormControl(''),
          bankCountryCode: new FormControl(''),
          accountNo: new FormControl(''),
          ifscCode: new FormControl(''),
          micrCode: new FormControl(''),
          swiftCode: new FormControl('')
        })
      ])
    });

我想知道如何删除
\u id
表单控件,因为控件很复杂,我不知道如何删除。请提供帮助。

这里的关键是导航表单结构。到达
\u id
所在的表单组后,可以使用
removeControl(“u id”)
删除该控件

const arr:FormArray=this.GSTNForm.get('gstandbankDetails')作为FormArray;
const grp:FormGroup=arr.get('0')作为FormGroup;
grp.removeControl(“id”);
我已经为每个导航创建了一个步骤,但如果您愿意,可以将其打包成一个巨大的调用

我的首选是将嵌套表单组存储为属性,然后您可以调用:

this.nestedGroup.removeControl('_id');

演示:

这里的关键是导航表单结构。到达
\u id
所在的表单组后,可以使用
removeControl(“u id”)
删除该控件

const arr:FormArray=this.GSTNForm.get('gstandbankDetails')作为FormArray;
const grp:FormGroup=arr.get('0')作为FormGroup;
grp.removeControl(“id”);
我已经为每个导航创建了一个步骤,但如果您愿意,可以将其打包成一个巨大的调用

我的首选是将嵌套表单组存储为属性,然后您可以调用:

this.nestedGroup.removeControl('_id');

演示:

您可以使用
removeControl

this.GSTNForm.get('gstandbankDetails').controls[0].removeControl('_id')

您可以使用
removeControl

this.GSTNForm.get('gstandbankDetails').controls[0].removeControl('_id')