-
Notifications
You must be signed in to change notification settings - Fork 25k
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
bug(forms): Value and status are out of sync in ngModelChange callback #21513
Comments
I'm a bit torn on this one. It's already possible to get the updated value by passing That said, at the end of the day, it's confusing behavior - esp when it comes to stale control status - and it's possible for people to save their own copy of the old value. So I'm thinking we should make the change and ensure we mark it as "breaking". |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
I'm submitting a...
Current behavior
Within the
ngModelChange
callback, the form validity doesn't reflect the control status. For example, if the value fails validation, the form control will still haveVALID
status.Expected behavior
If the value fails validation, I would expect
INVALID
status.Minimal reproduction of the problem with instructions
Consider the component:
where
onNgModelChange
is defined:If you the value goes from valid to invalid,
VALID
will be logged despite value beingINVALID
. When using async validators, one would expectPENDING
to be logged, but the previous status is logged instead.See #21514 for a test case.
What is the motivation / use case for changing the behavior?
I would like to filter out invalid values in the callback. As an aside, this was easier in AngularJS, where one could set
allowInvalid
tofalse
inngModelOptions
.Environment
The text was updated successfully, but these errors were encountered: