For one of my projects I needed undo/redo functionality. We implemented this by using just saving snapshots of the object to $sessionStorage.
However - we needed an easy way of being notified of object changes. Enter $scope.$watch. This method allows you to watch object for changes.
However - this method does not 'deep watch' into child property values. Also, we needed a bit more control over which model changes would trigger the snapshot mechanism. We solved it by adding a 'hash' method that creates a has of all the object properties that I care about.
Here's what I mean: http://jsfiddle.net/dsr4Y/2/
No comments:
Post a Comment