controller.js 400 B

123456789101112
  1. angular.module("myApp", []).
  2. controller("TreeController", ['$scope', function($scope) {
  3. $scope.delete = function(data) {
  4. data.nodes = [];
  5. };
  6. $scope.add = function(data) {
  7. var post = data.nodes.length + 1;
  8. var newName = data.name + '-' + post;
  9. data.nodes.push({name: newName,nodes: []});
  10. };
  11. $scope.tree = [{name: "Node", nodes: []}];
  12. }]);