How to apply pairwise pipe to FormGroup in Angular

65 views Asked by At

I have the next formGroup:

 name: Form_Group_Config,
    controls: {
        field1: [],
        field2: [],
        field3: [],
    }

In my component I want to subscribe to changes in all three fields and capture both the previous state and the current state.

const formGroupControls = this.parent.get(Form_Group_Config)! as FormGroup;

    formGroupControls.valueChanges
        .pipe(
            startWith(formGroupControls.value),
            distinctUntilChanged(),
            pairwise(),
            takeUntil(this.unsubscribe$)
        )
        .subscribe((value) => {
            console.log("Whole form subsc: ",value);
        })

In the console, I only observe changes for the first field. What could be the issue? I anticipated seeing three pairs for each field.

0

There are 0 answers