Fiddle link where we can add new child nodes, and their child node too, can delete the child node form the parent ONLY.
I am trying to delete all the child node and ALSO the current node from the same delete button. (All child node are deleted successfully but i am not able to delete the current node from the list.)
How can i do this via 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: []}];
}]);
Can anyone please help.