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.
            Asked
            
        
        
            Active
            
        
            Viewed 123 times
        
    4
            
            
        - 
                    That is just how it works. You could watch the properties individually if you really do not want to write code to figure it out. – aet Mar 16 '14 at 16:12
- 
                    Or try something like this: http://stackoverflow.com/questions/8572826/generic-deep-diff-between-two-objects – aet Mar 16 '14 at 20:01
1 Answers
0
            
            
        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.
External links for Object.observe()
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.
 
    
    
        Robin Andersson
        
- 5,150
- 3
- 25
- 44
