3

我目前正在使用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实现吗?

4

1 回答 1

4

我终于把它变成了这样:

我在目标范围中检查父级仍然是 uiTreeNode。

在控制器中:

$scope.treeOptions = {
    accept: function(sourceNodeScope, destNodesScope, destIndex) {

        if (destNodesScope.$parent.$type === "uiTreeNode"){
                return true;
        }else{
            return false;
        }

    }
  };

并认为:

<div ui-tree="treeOptions">
于 2016-02-05T20:10:07.743 回答