0
votes

I trying to add formGroup dynamically inside another formGroup without using formArray. And also add formControl in newly added formGroup dynamically. I have also tried addFormGroup() function but its giving error that this.form.addFormGroup is not a function.

1
can you provide some code which you have tried? - Ajay Ojha

1 Answers

0
votes

Is this what you are trying to achieve?

const f = new FormGroup({});
const userGroup = new FormGroup({});
f.addControl('user', userGroup);
userGroup.addControl('firstName', new FormControl('Vladimir'));
userGroup.addControl('lastName', new FormControl('Prudnikov'));
console.log(f.value);