Fiddle
link, where we can add new child nodes, and their child element node can also remove the child element node only for the parent.
I am trying to delete all child nodes and ALSO the current node from the same delete button. (All child nodes are deleted successfully, but I cannot remove the current node from the list.)
How can I do this with Angular Js.
angular.module("myApp", []).
controller("TreeController", ['$scope', function($scope) {
$scope.delete = function(data) {
data.nodes = [];
};
$scope.add = function(data) {
var post = data.nodes.length + 1;
var newName = data.name + '-' + post;
data.nodes.push({name: newName,nodes: []});
};
$scope.tree = [{name: "Node", nodes: []}];
}]);
Someone can help.
source
share