I have a large object laid out in $ rootScope (say> 100 objects, and each of them has a hierarchy of objects / array again), I want $ to watch the entire $ rootScope using deepWatching (i.e. turn the third parameter of $ watch in TRUE).
But the problem is this: $ watch returns 2 objects (i.e., one old RootScope and a modified RootScope). Then I have to go through the process of checking which attribute of the object has been changed in $ rootScope and its hierarchy to push it onto the stack.
Do we have an easy way to get the exact attribute changed when viewing $ scope?
$scope.$watch($rootScope, function(oldObj, newObj){
Alternatively, I could add a clock for each attribute of the Object, but it seems extremely expensive.
What is the best way to achieve undo / redo in angular js?
Note : -
angular -History is not suitable for my need, because I want to see all the attributes of an object, which may also contain other objects and an array.
I am sure that looking at just $ rootScope is not a good idea either, but I am aiming at creating a user interface that has several grids, drag n drop, can contain a form, elements can be removed. So I want to create a general solution for folding changes and roll it back to CTRL + Z. Imagine replicating the desktop version of Photoshop.
source share