3

I am currently using Angular UI Tree.

My object:

     [
          {
            "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"
              }
            ]
          }
        ]

What I want to achieve is to allow students to drag & drop inside classes (The classes do not have to be draggable, and students do not have to be dropped into first level (classes) only to a second level (students)).

Is this possible to achieve with Angular UI Tree?

Egidi
  • 1,736
  • 8
  • 43
  • 69

1 Answers1

4

I finally made It like this:

I check in the destination Scope that parent is still a uiTreeNode.

In controller:

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

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

    }
  };

and in view:

<div ui-tree="treeOptions">
Egidi
  • 1,736
  • 8
  • 43
  • 69