I have a tree view. A user can select a node, then edit configuration of that node. I would like a way to detect whether this has changed at all from the original.
All examples I've seen of $watch happens on a scope level and don't allow me to see when a model has changed. How can I setup a watch (or something similar) that will tell me which object was changed so that I can do something like
$scope.itemChanged = function(item) {
item.hasChanged = angular.equals(item, item.original);
}
I have tried deep watch examples like in this answer but they tell me only that the entire tree has changed, rather than which node. e.g.
$scope.$watch('tree', function (oldValue, newValue, scope) {
console.log("changed", oldValue, newValue, scope);
}, true);
$watch(function(){ return changedNode }, function(newVal){ }), but I would recommend capturing the changes inng-changeof inputs, rather than with a deep-watch