forked from itarato/AngularJSTree
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmindmap.js
More file actions
28 lines (24 loc) · 713 Bytes
/
Copy pathmindmap.js
File metadata and controls
28 lines (24 loc) · 713 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
function MindMap($scope) {
$scope.tree = {'title': 'Root'};
$scope.input = {'title': ''};
$scope.add_child = function(parent_node) {
var child_node = {'title': $scope.input.title, 'parent': parent_node};
if (parent_node.children) {
parent_node.children.push(child_node);
}
else {
parent_node.children = [child_node];
}
$scope.input.title = '';
};
$scope.delete_child = function(child_node_to_delete) {
var parent = child_node_to_delete.parent;
for(var i=0; i<parent.children.length; i++) {
var child_node = parent.children[i];
if (child_node == child_node_to_delete) {
parent.children.splice(i,1);
break;
}
}
};
}