Form array of form group , get changes for exact specific control - angular

0

I have my form structure as below …

this.myForm =  this.formBuilder.group({
 control1: this.formBuilder.control({value: ''}),
 groupcontrol1: this.formBuilder.array({ this.addGroupControl() });
});


addGroupControl(): FormGroup {
   return this.formBuilder.group({
     recurringControl1: this.formBuilder.control({value: ''}),
     recurringControl2: this.formBuilder.control({value: ''}),
     recurringControl3: this.formBuilder.control({value: ''}),
    });
  });

now for each of the recurring control I need to get notified for exact which recurring control value got changed and the index of that form group , for this I am using below code – this code is for
recurringControl1

 merge(
      ...this.myForm
        .get('groupcontrol1')
        .controls.map((eachGroup, index: number) =>
          eachGroup.controls.recurringControl1.valueChanges
           .pipe(map((value) => ({ rowIndex: index, control: eachGroup, data: value })))
        )
    ).subscribe((changes) => {
      console.log(changes);
    });

using above code , I am getting recurringControl1 value only from 1st form group , not other form groups . basically only when row index is 0 , only getting that value

any modification or suggestion on above code to get exactly which control out of the 3 recurring controls value changed

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.