angular-ui-tree
Version:
An AngularJS UI component that can sort nested lists, provides drag & drop support and doesn't depend on jQuery
89 lines (80 loc) • 1.82 kB
JavaScript
(function () {
'use strict';
angular.module('demoApp')
.controller('FilterNodesCtrl', ['$scope', function ($scope) {
$scope.remove = function (scope) {
scope.remove();
};
$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.visible = function (item) {
return !($scope.query && $scope.query.length > 0
&& item.title.indexOf($scope.query) == -1);
};
$scope.findNodes = function () {
};
$scope.data = [{
'id': 1,
'title': 'node1',
'nodes': [
{
'id': 11,
'title': 'node1.1',
'nodes': [
{
'id': 111,
'title': 'node1.1.1',
'nodes': []
}
]
},
{
'id': 12,
'title': 'node1.2',
'nodes': []
}
]
}, {
'id': 2,
'title': 'node2',
'nodes': [
{
'id': 21,
'title': 'node2.1',
'nodes': []
},
{
'id': 22,
'title': 'node2.2',
'nodes': []
}
]
}, {
'id': 3,
'title': 'node3',
'nodes': [
{
'id': 31,
'title': 'node3.1',
'nodes': []
}
]
}, {
'id': 4,
'title': 'node4',
'nodes': [
{
'id': 41,
'title': 'node4.1',
'nodes': []
}
]
}];
}]);
}());