You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
Writing directives to handle input of collections (lists or objects) is currently not very well supported because ngModelController uses identity tests to determine if the model or view value changes.
Adding a collection watch mode to ngModelController would allow for more robust input directives such as checkbox lists to work without having to do things like creating new lists on every update or monkey patching the ngModelController instance.
This issue has come up a few times, but the only place I could find it yesterday was in #2553, which is closed.
The text was updated successfully, but these errors were encountered:
I'm considering writing a patch for this, but I'd like some input on the API.
Possibilities I've considered and rejected are:
model.$watcher = function() { ... }, doesn't address the comparisons that happen outside of the watcher function.
model.$isEqual = function(curr, prev) { ... } requires copying lists and objects for later comparison, we may as well just use scope.$watchCollection().
model.$collectionMode = true is pretty simple and it could be observed inside ngModelWatch() and $setViewValue(), but I think we want scope.$watchCollection().
So I think the API that would work is model.$collectionMode(true).
This still feels a bit funny to me because the watch has already started by the time we're calling it so the $collectionMode function has to undo the initial watch and start a collection watch. Maybe moving the watch to the linking function and adjusting priority could work around this? I guess I could try it and see what breaks.
Writing directives to handle input of collections (lists or objects) is currently not very well supported because
ngModelController
uses identity tests to determine if the model or view value changes.Adding a collection watch mode to
ngModelController
would allow for more robust input directives such as checkbox lists to work without having to do things like creating new lists on every update or monkey patching thengModelController
instance.This issue has come up a few times, but the only place I could find it yesterday was in #2553, which is closed.
The text was updated successfully, but these errors were encountered: