1
votes

I can update a FormControl inside of FormGroup like this:

form.setControl('happyControl',
   new FormControl('happy value', Validators.required)
);

But inside of a FormArray, I can't edit picked FormControl.

In myForm controls > FormArray > FormGroup, I can't set the control. My code is like this:

let firstFormGroup = form.controls.myFormArrayControl.controls;

firstFormGroup[0].setControl('happyControl', 
    new FormControl('sad value', Validators.minlength(2))
);

How can I access and update the control?

1
Does is work when you try to update the control at a specific index, like this: firstFormGroup[0].setControl('happyControl'... ?R. Richards
@R.Richards I tried like you write, I can see the value in FormGroup object but view is not updating. I can't understand. I am trying to solve this for 3 days...Sam

1 Answers

0
votes

You must call updateValueAndValidity().

I think like that, but it would help if you publish the complete code:

firstFormGroup[0].updateValueAndValidity()