ngneat / reactive-forms

(Angular Reactive) Forms with Benefits 😉
https://www.netbasal.com
611 stars 56 forks source link

valueChanges - emit values only when form gets updated by new values #148

Closed Mohendran closed 2 years ago

Mohendran commented 2 years ago

Is this a regression?

No

Description

Completed the migration work for angular version 12 after that I am facing an issue with valueChanges subscription. currently, valueChanges triggering when initiating the form. Check the code below.

Expected is valueChanges should not trigger when initiating the form.

form = new FormGroup({ name: new FormControl('', { validators: [ Validators.required ], updateOn: 'blur', }), description: new FormControl('', { updateOn: 'blur' }) });

this.form.valueChanges .pipe( untilDestroyed(this), ).subscribe((data) => { if (this.form.valid) { console.log('trigger API'); } });

Please provide a link to a minimal reproduction of the bug

https://stackblitz.com/edit/angular-ivy-ei4kz1?file=src%2Fapp%2Fapp.component.ts

Please provide the exception or error you saw

No response

Please provide the environment you discovered this bug in

development & production

Anything else?

No response

Do you want to create a pull request?

No

NetanelBasal commented 2 years ago

It's related to material. It works fine https://stackblitz.com/edit/angular-ivy-gszcze?file=src%2Fapp%2Fapp.component.html