Reputation: 143
I'm having issue on removing the FormArray from ReactiveForm.
I have the following code :
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());
}
Now for deletion the formControl surveyName I just do
this.survey.removeControl('surveyName');
And above code is working fine for surveyName. But what thing i can use for deletion the form array sections. I want to delete the whole section object with key.
Upvotes: 6
Views: 11348