Reputation: 27394
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);
Upvotes: 0
Views: 175
Reputation: 59
I have not done much angularjs but your question intrigued me so I think this post may help you angularjs treeview. The example has what I think you're looking for because it returns the .selectNodeHead that you can manipulate.
&(c.angularTreeview?(a.$watch(e,function(m,b){g.empty().html($compile(k)(a))},!1),a.selectNodeHead=a.selectNodeHead||function(a,b){b.stopPropagation&&b.stopPropagation()
Keep coding. Cheers
Upvotes: 1