My challenge involves a large object stored in $rootScope with over 100 objects, each containing hierarchies of objects and arrays. I am seeking to watch the entire $rootScope using deepWatching (setting the 3rd parameter of $watch to TRUE).
The issue arises when $watch returns two objects - the Old RootScope and the Modified RootScope. This requires me to analyze which attribute of the object changed within $rootScope and its hierarchy in order to push it into a stack.
Is there a straightforward method to identify the exact attribute that has changed while watching a $scope?
$scope.$watch($rootScope, function(oldObj, newObj){
//I need to pinpoint the specific attribute that changed, not just the entire objects!
}, true);
Alternatively, I could individually watch each attribute of the object but this approach seems overly resource-intensive.
What is the most effective way to implement undo/redo functionality in AngularJS?
Note:
The angular-history solution does not meet my requirements as I need to monitor all attributes of an object, some of which may contain other objects and arrays.
I understand that watching the entire $rootScope may not be optimal, however, I am developing a UI with multiple grids, drag-and-drop features, possibly forms, and elements that can be deleted. Therefore, I aim to create a comprehensive solution for tracking changes and enabling undo functionality with CTRL + Z. Think of replicating the desktop version of Photoshop.