我目前正在使用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可以实现吗?
答案 0 :(得分:4)
我终于做到了这样:
我在目标范围内检查父级仍然是uiTreeNode。
在控制器中:
$scope.treeOptions = {
accept: function(sourceNodeScope, destNodesScope, destIndex) {
if (destNodesScope.$parent.$type === "uiTreeNode"){
return true;
}else{
return false;
}
}
};
并在视野中:
<div ui-tree="treeOptions">