Reputation: 87
I have a method, that returns a FormGroup object.
public static createFormGroup(...): FormGroup { ... returns formGroupWithControls}
Generally, I already have a FormGroup within a FormArray. I want to create new FormGroups and replace the value of the FormGroup (in the FormArray) with the value of the new created FormGroup (from the above method)
this.removeControls(); // removes all Controls in "formGroupReferencedInFormArray"
this.formGroupReferencedInFormArray.patchValue(FormGroupFactory.createFormGroup(...));
After this call the FormGroup "formGroupReferencedInFormArray" is empty... But I would like to have the value of the returned FormGroup within "formGroupReferencedInFormArray".
Upvotes: 0
Views: 789
Reputation: 11979
You could use formArray.setControl(index, youFormGroupInstance)
.
Upvotes: 1