2025-06-27 10:04:22 +08:00

89 lines
2.3 KiB
JavaScript

(function () {
'use strict';
angular.module('app')
.controller('treeCtrl', ['$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);
alert( angular.toJson(item));
};
$scope.findNodes = function () {
};
$scope.data = [{
'id': 1,
'title': '',
'nodes': [
{
'id': 11,
'title': '',
'nodes': [
{
'id': 111,
'title': '',
'nodes': []
}
]
},
{
'id': 12,
'title': 'yu1.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': []
}
]
}];
}]);
}());