This is my form:
this.addForm = this.formBuilder.group({
details: this.formBuilder.array([]),
});
I am calling this function to push control
nestedFormGroupDetails(control) {
control.push(
this.formBuilder.group({
name: ['', [Validators.required]],
age: ['', [Validators.required]]
}));
**// based on scenario, I want to insert new control. ex. occupation
this.detailsFormArray.insert(0, [...]) // how to add abstract control here**
}
get detailsFormArray() {
return this.addForm.get('details') as FormArray
}
Pls suggest me whether I am doing it right way and also pls advise how can I insert/push new control in specific index, ex- index 0 Thanks in Advance