Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

fix(input): trigger modelValue update on viewValue property changes #8047

Closed

Conversation

petebacondarwin
Copy link
Contributor

If the $viewValue is an object then we should trigger a model update
if properties on that object change.

Previously, we were only checking for change of object identity.

Closes #7965

@mary-poppins
Copy link

Thanks for the PR! Please check the items below to help us merge this faster. See the contributing docs for more information.

  • Uses the issue template (#8047)

If you need to make changes to your pull request, you can update the commit with git commit --amend.
Then, update the pull request with git push -f.

Thanks again for your help!

@petebacondarwin
Copy link
Contributor Author

Here is a Plunker with the angular.js file patched accordingly to demonstrate that this works.
http://plnkr.co/edit/d7Yl73fLzQBVqlutI9ID?p=preview

If the $viewValue is an object then we should trigger a model update
if properties on that object change.

Previously, we were only checking for change of object identity.

Closes angular#7965
@petebacondarwin
Copy link
Contributor Author

Since this fix relies upon angular.copy in the same way that $watch does, we would need to fix this along the same lines as #8040

return;
}
ctrl.$$lastCommittedViewValue = viewValue;
ctrl.$$lastCommittedViewValue = copy(viewValue);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the copy should be done as early as possible (in $setViewValue) and not here, otherwise updates to the object that was passed in might effect ctrl.$viewValue, ctrl.$modelValue and the scope bound to it.

@petebacondarwin
Copy link
Contributor Author

Closing as not the right solution. See the original issue #7965 for more information

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

Successfully merging this pull request may close these issues.

[1.3-beta16] ngModel $parsers regression vs. v1.2
3 participants