How to clone node in Angular UI tree with all children?
Now I use event click: ng-click="newSubItem(this)"
where newSubItem
is function:
$scope.newSubItem = function (scope) {
var nodeData = scope.$modelValue;
var arrr_nodes = [];
angular.forEach(nodeData.nodes, function (value) {
arrr_nodes.push(arrr_nodes);
});
var total_nodes = nodeData.nodes.length;
var prefix_increment = total_nodes + 1;
nodeData.nodes.push({
id: nodeData.id + prefix_increment,
prefix: nodeData.prefix + "_" + prefix_increment,
title: nodeData.title + '.' + (nodeData.nodes.length + 1),
value: nodeData.value,
type: nodeData.type,
nodes: arrr_nodes
});
};
When I try to insert all children from cloned object to new nodes: nodes: arrr_nodes
it gives a lot of errors and breaks tree.