1

I am using angular treeview to build a tree using AngularJS. I am able to add a new child, as well as new node in my application.

  1. I am able to add new node as well as child for selected node
  2. I am able to Edit the selected node as well as child

Below jsfiddle link have Add/Edit node.

https://jsfiddle.net/eu81273/48cafgsu/

I need to delete the selected node.

Please help me in this. Thanks in advance.

0

1 Answer 1

1

hello i updated your fiddle to be able to delete a node

https://jsfiddle.net/48cafgsu/56/

     Array.prototype.remove = function() {
    var what, a = arguments,
      L = a.length,
      ax;
    while (L && this.length) {
      what = a[--L];
      while ((ax = this.indexOf(what)) != -1) {
        this.splice(ax, 1);
      }
    }
    return this;
  }

  var getSubMenuItem = function(subMenuItems, node) {
    console.log(subMenuItems)
    console.log(node)

    var current_node = subMenuItems;

    if (subMenuItems) {
      for (var i = 0; i < subMenuItems.length; i++) {
        if (subMenuItems[i].id == node.id) {
          current_node = current_node.remove(node);
          console.log('removed')
         // subMenuItems =current_node
          return

        }

        if(subMenuItems[i].children.length>0){

        getSubMenuItem(subMenuItems[i].children,node)


        }



      }
    }
  };
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.