'Angular Ivy - Adding dynamic controls to an existing form groups within form array

Using Angular Reactive Forms module, i have a case where my form array being populated with few form groups, in a specific case for example "on destroy" i would like to add controls to each of the form groups inside my form array, i tried iterating over the array and using addcontrol but something mess up smh, code below thanks for help

<FormArray>this.form.get('additionals')).controls.forEach(
    (control) => {console.log(
      control.addControl('new', new FormControl('', Validators.required))
    )}

in result i get > Property 'addControl' does not exist on type 'AbstractControl'. i dont know why i get such error, as far as i know from Angular io docs addControl is method of AbstractControl which FormGroup is instance of it. so why it error?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source