Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Mohendran opened this issue Feb 28, 2022 · 1 comment
Closed

Comments

@Mohendran
Copy link

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
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants