【问题标题】:Angular UI Tree - Allow only drag & drop into second level (children nodes)Angular UI Tree - 只允许拖放到第二级(子节点)
【发布时间】:2016-05-15 21:28:55
【问题描述】:

我目前正在使用Angular UI Tree

我的对象:

     [
          {
            "id": 1,
            "title": "class1",
            "students": [
              {
                "id": 11,
                "title": "student1.1",
              },
              {
                "id": 12,
                "title": "student1.2"
              }
            ]
          },
          {
            "id": 2,
            "title": "class2",
            "students": []
          },
          {
            "id": 3,
            "title": "class3",
            "students": [
              {
                "id": 31,
                "title": "student3.1"
              }
            ]
          }
        ]

我想要实现的是允许学生在班级内拖放(班级不必是可拖动的,学生不必被拖放到第一级(班级)只到第二级(学生) )。

这可以通过 Angular UI Tree 实现吗?

【问题讨论】:

    标签: javascript angularjs tree drag-and-drop angular-ui-tree


    【解决方案1】:

    我终于做到了:

    我在目标 Scope 中检查 parent 仍然是一个 uiTreeNode。

    在控制器中:

    $scope.treeOptions = {
        accept: function(sourceNodeScope, destNodesScope, destIndex) {
    
            if (destNodesScope.$parent.$type === "uiTreeNode"){
                    return true;
            }else{
                return false;
            }
    
        }
      };
    

    在视野中:

    <div ui-tree="treeOptions">
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-27
      • 2021-12-21
      • 1970-01-01
      • 2014-11-12
      相关资源
      最近更新 更多