Reputation: 1527
I have an object with deep watch on it (true in the third argument of $watch). When the watch is triggered I want to know which property was changed. All I'm getting is the new and old value. Is there a good way to know what was changed? I don't want to compare new and old objects and search for the changed properties.
Upvotes: 4
Views: 128
Reputation: 5390
Not the cleanest way, but a non pure AngularJS way to solve this is to use Object.observe()
on the object instead of $watch, because it passes on the name of the changed property.
Another way would be to override the getters and setters on the object so they create a changed property list that is stored internally in the object. Not sure about the exact implementation of this, and it isn't that clean either.
Upvotes: 0