-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathnestedApp.js
53 lines (52 loc) · 1.32 KB
/
nestedApp.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
angular.module('nestedApp', ['ng-sortable'])
.component('nestedDragAndDropExample', {
template: `<ul id='main-list' ng-sortable="$ctrl.sortableConf">
<li ng-repeat="item in $ctrl.items" >
<span id={{item.name}}> {{ item.name }} </span>
<div ng-if="item.items">
<ul class='nested-list' ng-sortable="$ctrl.nestedSortableConf">
<li ng-repeat="subitem in item.items" >
<span id={{subitem.name}}> {{ subitem.name }} </span>
</li>
</ul>
</div>
</li>
</ul>`,
controller: class ExampleAppController {
constructor() {
var _this = this;
this.items = [{
name: 'item1',
items: [
{
name: 'subitem1',
}
]
},
{
name: 'item2',
items: [
{
name: 'subitem2',
}
]
},
{
name: 'item3'
}]
this.onEnd = function(event) {
_this.lastDragged = event.model;
}
this.sortableConf = {
group: 'all',
forceFallback: true,
onEnd: this.onEnd
}
this.nestedSortableConf = {
group: 'all',
forceFallback: true,
onEnd: this.onEnd
}
}
},
})