As in the documentation $ callbacks (type: object)
$ callbacks is a very important property for angular -ui-tree. When some special events trigger, functions from $ callbacks are called. callbacks can be passed through a directive.
you define events in the treeOptions collection
myAppModule.controller('MyController', function($scope) {
$scope.treeOptions = {
accept: function(sourceNodeScope, destNodesScope, destIndex) {
return true;
},
dropped: function(e) {
console.log (e.source.nodeScope.$modelValue);
}
};
});
then in your div tree add callbacks = "treeOptions" , which you defined above in the controller
<div ui-tree callbacks="treeOptions">
<ol ui-tree-nodes ng-model="nodes">
<li ng-repeat="node in nodes" ui-tree-node>{{node.title}}</li>
</ol>
</div>
then you can access the old parent from here
e.source.nodeScope.$parentNodeScope.$modelValue
and you can access the new parent from here
e.dest.nodesScope.$parent.$modelValue
source
share