angular-ui-tree
Version:
An AngularJS UI component that can sort nested lists, provides drag & drop support and doesn't depend on jQuery
60 lines (54 loc) • 1.28 kB
JavaScript
(function () {
'use strict';
angular.module('demoApp')
.controller('ConnectedTreesCtrl', ['$scope', function ($scope) {
$scope.remove = function (scope) {
scope.remove();
};
$scope.toggle = function (scope) {
scope.toggle();
};
$scope.newSubItem = function (scope) {
var nodeData = scope.$modelValue;
nodeData.nodes.push({
id: nodeData.id * 10 + nodeData.nodes.length,
title: nodeData.title + '.' + (nodeData.nodes.length + 1),
nodes: []
});
};
$scope.tree1 = [{
'id': 1,
'title': 'tree1 - item1',
'nodes': []
}, {
'id': 2,
'title': 'tree1 - item2',
'nodes': []
}, {
'id': 3,
'title': 'tree1 - item3',
'nodes': []
}, {
'id': 4,
'title': 'tree1 - item4',
'nodes': []
}];
$scope.tree2 = [{
'id': 1,
'title': 'tree2 - item1',
'nodes': []
}, {
'id': 2,
'title': 'tree2 - item2',
'nodes': []
}, {
'id': 3,
'title': 'tree2 - item3',
'nodes': []
}, {
'id': 4,
'title': 'tree2 - item4',
'nodes': []
}];
}]);
}());