I am working on Angular forms data driven approach, I added form controls dynamically to FormArray, I used form.reset() to reset the added controls, but form.reset() doest not reset the FormArray length, I have found that this is a known issue and can be solved using this approach, https://github.com/angular/angular/pull/11051 , but still I am unclear about this. Please help, Thanks
reviewForm: FormGroup;
ngOnInit(){
this.reviewForm = new FormGroup({
'controlArray': new FormArray([
])
});
}
onSubmit(){
this.formData = new FormData(this.formService.formName, this.reviewForm.value.controlArray);
let formControls = JSON.stringify(this.formData);
// console.log(formControls);
this.formService.createForm(formControls)
.subscribe(
data => console.log(data),
error => console.error(error)
);
this.reviewForm.reset();
}