【问题标题】:Angular treeview delete selected node角度树视图删除选定的节点
【发布时间】:2016-05-29 19:15:48
【问题描述】:

我正在使用 Angular treeview 使用 AngularJS 构建树。我可以在我的应用程序中添加一个新子节点以及新节点。

  1. 我可以为选定节点添加新节点和子节点
  2. 我可以编辑所选节点以及子节点

下面的 jsfiddle 链接有添加/编辑节点。

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

我需要删除选中的节点。

请帮助我。提前致谢。

【问题讨论】:

    标签: angularjs treeview


    【解决方案1】:

    你好,我更新了你的小提琴以能够删除一个节点

    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)
    
    
            }
    
    
    
          }
        }
      };
    

    【讨论】:

      猜你喜欢
      • 2015-01-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多