Closed hegoku closed 5 years ago
To have a function in the directive (just like add_branch) would be great.
For the meantime I worked around this by travelling the tree and replacing the data:
function deleteTreeItems(tree, items) {
for (var i = 0; i < tree.length; i++) {
for (var j = 0; j < items.length; j++) {
if (tree[i].id == items[j].id) {
tree.splice(i,1);
i = 0;
} else {
if (tree[i].children.length > 0) {
tree[i].children = deleteTreeItems(tree[i].children, items);
}
}
}
}
return tree;
}
Yep, Great!
On 7 September 2016 at 18:11, guicoma notifications@github.com wrote:
To have a function in the directive (just like add_branch) would be great.
For the meantime I worked around this by travelling the tree and replacing the data:
function deleteTreeItems(tree, items) { for (var i = 0; i < tree.length; i++) { for (var j = 0; j < items.length; j++) { if (tree[i].id == items[j].id) { tree.splice(i,1); i = 0; } else { if (tree[i].children.length > 0) { tree[i].children = deleteTreeItems(tree[i].children, items); } } } } return tree; }
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/nickperkinslondon/angular-bootstrap-nav-tree/issues/106#issuecomment-245236262, or mute the thread https://github.com/notifications/unsubscribe-auth/AErkbyLzXSgfwzdfkFY2lh3gXyiBqKNCks5qno3qgaJpZM4JdcqJ .
Hello,
There's already a PR for this, so I'm not gonna create another. Anyway, I did it like this.
tree.remove_branch = function(branch) {
if (branch != null) {
var parent = get_parent(branch);
// Make sure we have a parent
if(parent != null) {
parent.children.splice(parent.children.indexOf(branch), 1);
}
}
};
Duplicate of #36
I can't find a delete function in source code... Is there any solutions? Thanks!