AngularJS tree demo

1、效果图




2、代码
js、css

<script type="text/javascript"
	src="editor-app/libs/angular_tree/angular-tree-control.js"></script>
<link rel="stylesheet" type="text/css"
	href="editor-app/libs/angular_tree/tree-control.css">
<link rel="stylesheet" type="text/css"
	href="editor-app/libs/angular_tree/tree-control-attribute.css">


关键代码

<script type="text/javascript">
angular.module('app', ['treeControl']).controller('MyCtrl', ['$scope',function($scope){
//treeOptions
$scope.treeOptions = {
	    nodeChildren: "children",
	    dirSelectable: true,
            multiSelection:true,
	    injectClasses: {
	        ul: "a1",
	        li: "a2",
	        liSelected: "a7",
	        iExpanded: "a3",
	        iCollapsed: "a4",
	        iLeaf: "a5",
	        label: "a6",
	        labelSelected: "a8"
	    }
}
//groupsTreeModel
$scope.groupsTreeModel=
[
	{ "name" : "总公司", "age" : "29", "children" : [
	        { "name" : "市场销售部", "age" : "21", "children" : [
	               { "name" : "销售部", "age" : "42", "children" : [] },
	               { "name" : "市场部", "age" : "21", "children" : [
	                        { "name" : "国内市场部", "age" : "23", "children" : [
	                                 { "name" : "华东市场", "age" : "32", "children" : [] },
	                                 { "name" : "中部市场", "age" : "34", "children" : [] }
	                         ]}
	               ]}
	        ]},
	        { "name" : "财务部", "age" : "33", "children" : [
	        		 { "name" : "会计部", "age" : "25", "children" : [] },
	         		 { "name" : "出纳部", "age" : "28", "children" : [] }
	        ]},
	        { "name" : "法务部", "age" : "29", "children" : [] }
	] }
];

}]);
//item click
$scope.onTreeLeafItemClickFunction = function(sel) {
	//alert(sel.name);
    $scope.selectedNode = sel;
};
//father node expanded
$scope.onTreeFatherNodeExpandFunction=function(exp){
	//alert('expand');
	alert('expand:'+exp.name);
}
}]);
</script>

<!-- body #s -->
<body ng-controller="MyCtrl">
		<div treecontrol 
	     class="tree-light" 
	     tree-model="groupsTreeModel"
		 on-selection="onTreeLeafItemClickFunction(node)"
		 on-node-toggle="onTreeFatherNodeExpandFunction(node)"
		 options="treeOptions"
		 >{{node.name}}</div>
</body>
<!-- body #e -->


3、与activiti editor集成时

var activitiModeler = angular.module('activitiModeler', [
  'ngCookies',
  'ngResource',
  'ngSanitize',
  'ngRoute',
  'ngDragDrop',
  'mgcrea.ngStrap', 
  'ngGrid',
  'ngAnimate',
  'pascalprecht.translate',
  'duScroll',
  'treeControl'
]);
/*add tree component: treecontrol*/




angular.module('activitiModeler').controller('myCandidateGroupsController', ['$scope','$http','myCache', function($scope,$http,myCache){
//add your code
}]);

4、api
http://wix.github.io/angular-tree-control/
  • 大小: 4.8 KB
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值