-
Notifications
You must be signed in to change notification settings - Fork 27.4k
$setViewValue() method also change the $modelValue #8131
Comments
This is related to the discussion in #7976 |
Hmmm... Have you tried to write a formatter and a parser? The former allows translating the model into the view value while the later does the reverse (translating the view value into the model). |
It's related to what @caitp said - the methods of ngModelController, especially $setViewValue do too much - if we expose them to the developer they should be consistent. |
@Narretz, what I'm trying to say is that the proper Angular-way to do what @kamalpatel125 needs is using parsers and formatters, so he shouldn't need to call |
On re-reading, I agree that this use case is possible with parsers / formatters, and that $setViewValue changes the modelValue by design, otherwise the two values would fall out of sync. |
Hi There,
I have input text box control where i need display and model value different.
e.g. but instead of personid, i like to show "full name".
For that, I added directive to $setViewValue() for this input control element. But $setViewValue() method also change the $modelValue as well. So I don't see any benefit's of setting viewValue if it is changing the modelValue as well.
Line no : 16690 (AngularJS v1.2.10-build.2164+sha.8b395ff). Also, I checked the latest version and code looks the same.
If you need more information please let me know. Hope someone can help me on this issue.
Thanks
Kamal Patel.
The text was updated successfully, but these errors were encountered: