首页 > 解决方案 > 删除嵌套表单组内的对象

问题描述

我正在从事角度反应形式项目。我需要删除嵌套表单组中的对象

this.surveyForm = this.fb.group({
      name: [null],
      _id: [null],
      question: [null],
      from_list: [true],
      type: CampaignActivityType.Survey,
      questionList:this.fb.group({
      question: ['', Validators.required],
      answers:this.fb.group({
      answer: ['', Validators.required]
    });
    });
)
    });

我需要删除特定索引中的答案对象

标签: angularangular6angular-reactive-forms

解决方案


Try this:

//Remove:
this.surveyForm.get('answers').removeControl('answer');

推荐阅读