-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
Change Detection Quirk with NgForm.resetForm() #19835
Comments
I should mention that if I call
This issue does not appear. The problem is that
should always set the Also, I said
I was wrong. Actually, it seems to happen if the control's value is |
Sounds like an issue that needs to be fixed. Can you please create a running example of your reproduction? We suggest using StackBlitz as you will get a full VSCode environment. |
This is actually working as expected. If you want to reset the form to a certain value, you must pass that value into the reset function.
|
This isn't working as expected: this.user = new User(); Is clearing the fields, but it isn't doing this:
|
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
Right after calling
resetForm()
on an instance ofNgForm
(to clear out validation and mark everything as pristine) I then change a value that one of form controls is bound to (using template-driven forms andngModel
). The control does not update with the new value, but instead gets stuck with thenull
value thatresetForm()
sets on it. This only happens if the control is untouched.Expected behavior
Change detection should pick up the change I make to the
ngModel
-bound variable after callingresetForm()
.Minimal reproduction of the problem with instructions
Using the example below
What is the motivation / use case for changing the behavior?
The behavior is confusing. Even if we don't change Angular's response, it should probably be documented somewhere.
Environment
The text was updated successfully, but these errors were encountered: