我在从ReactiveForm删除FormArray时遇到问题。
我有以下代码:
ngOnInit() {
this.survey = new FormGroup({
surveyName: new FormControl(''),
sections: new FormArray([
this.initSection(),
]),
});
}
initSection(){
return new FormGroup({
sectionTitle : new FormControl(''),
sectionDescription : new FormControl(''),
});
}
addSection(){
const control = <FormArray>this.survey.controls['sections'];
control.push(this.initSection());
}
Run Code Online (Sandbox Code Playgroud)
现在要删除formControl surveyName我只是做
this.survey.removeControl('surveyName');
Run Code Online (Sandbox Code Playgroud)
上面的代码对于SurveyName工作正常。但是我可以使用什么删除表单数组部分。我想用键删除整个节对象。