1

I am using Angular14 reactive form. I have a requirement where i want to reset the value of formcontrol and doesnt want to fire the form value changes. But even though i use {emitEvent: false}, the form valuechanges keeps firing indefinitely. Can anyone help how to fix this?

this.questionForm.controls['responseType']
.patchValue(questionAttributes.questionType, {emitEvent: false});

    

this.questionForm.valueChanges
            .pipe(takeUntil(this._destroy$))
            .subscribe((dataValue) => {
                   //it keeps firing indefinitely
                });

How to stop having the valuechanges getting fired.

Thanks

Mukil Deepthi
  • 6,072
  • 13
  • 71
  • 156
  • Cannot reproduce. [Demo](https://stackblitz.com/edit/angular-ivy-xjs7m3?file=src/app/app.component.ts). Are you sure it is due to this form control? Or is there any other form controls also update at the same time? – Yong Shun Jul 28 '22 at 06:58

1 Answers1

0

Make sure you are also blocking propagation from FormControl enable()/disable() calls:

this.formGroup.get('procedure').disable({ emitEvent: false });
this.formGroup.get('organization').enable({ emitEvent: false });
Diego Victor de Jesus
  • 2,575
  • 2
  • 19
  • 30