Detect changes of FormArray children

Viewed 5975

I have a FormArray with different FormControl items inside it. I want to be able to listen to the change event of any of them.

I tried to do this:

this.form = this.fb.group({
    items: this.fb.array([this.fb.control('')])
});

(<FormArray>this.form.get('items')).controls.forEach((control: FormControl) => {
    control.valueChanges.subscribe(change => console.log(change));
});

But I never seem to get to the console.log, even though I am sure that the children controls are firing up a change event (from ControlValueAccessor interface).

What would be the way to subscribe to the change of children controls of a FormArray?

1 Answers
 this.form.get('items').valueChanges.subscribe(changes=> {
     console.log(changes)
 })
Related