angular-tree-control
angular-tree-control copied to clipboard
sometimes not work when tree-mode is array
sometimes it not work when tree-mode is array
when I use it like:
// treeData is the tree-model
$scope.treeData = [];
var item={Name: "aaa", children:[]}
$scope.treeData.push(item)
// then do something with a call back function with item's children
but sometimes the tree can't refresh
I add "deepinWatch" argument in the $watch function of angular-tree-control, then it works, code is like:
scope.$watch("treeModel", function updateNodeOnRootScope(newValue) {
if (angular.isArray(newValue)) {
if (angular.isDefined(scope.node) && angular.equals(scope.node[scope.options.nodeChildren], newValue))
return;
scope.node = {};
scope.synteticRoot = scope.node;
scope.node[scope.options.nodeChildren] = newValue;
}
else {
if (angular.equals(scope.node, newValue))
return;
scope.node = newValue;
}
}, true);