-
Notifications
You must be signed in to change notification settings - Fork 27.4k
WIP: Feat: watch ngModel with object equality via ngModelOptions #12783
Conversation
// options.deepWatch | ||
// options.collection | ||
|
||
getModelValueSetter(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using get in the name is kind of confusing, since it's not returning anything.
9a49432
to
0814a6d
Compare
I would like to get away from doing so much work in the How about we move processing of If we could move everything out then we could solve this problem by letting the input directive decide what watching mechanism to use (i.e. simple watch, deep watch or watch collection). I think to begin with the input directive ought to be responsible for making the decision about the type of model. But then in my POC, I allowed parsers and formatters to convert the model that was being passed through from simple to collection and back again by setting a flag. |
Putting the burden on ngChange would be great. I'm just a tiny bit worrying about BC, which I wanted to avoid at this point. Who decides what kind of watching ngModel uses is imo separated from the fact thatit has to be implemented in ngModel anyway. |
|
An even better idea may be to allow customization of the function used to test equality rather than setting it to Consider a |
@dcherman - I hear what you are saying. I wonder if this could be approached by allowing There is an additional issue, though, which is that when we are not using Another thing to consider, is that in |
This is a first draft for watching models with object equality.
Use cases:
Notes:
For ngList / (select, url, email) multiple to use deepWatch, I can think of two ways:
$isCollection
, that tells the controller to use deepWatch. This could still be overruled if deepWatch is explicitly set tofalse
. This is however not very obvious for people who have their own controls. ngModelOptions would centralize everything.