xn-select.html
3.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<html ng-app="myApp">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题</title>
<link href="../directive/style.css" rel="stylesheet">
<link rel="stylesheet" href="../spm_modules/xn-style-common/1.0.1/xn-style-common.less">
<link rel="stylesheet" href="../spm_modules/xn-icon-common/1.0.5/iconfont.css">
<link rel="stylesheet" href="../spm_modules/bootstrap-css/1.0.0/bootstrap.css">
</head>
<body ng-controller="MyController">
<div style="width: 200px;margin: auto">
<h3>单选</h3>
<div class="clearfix"></div>
<div > {{selectdata}}</div>
<div xn-select-tree type="text" ng-model="selectdata" select-data="source1List" select-method="selectMethod(data)" name="result"></div>
<h3>多选</h3>
<div class="clearfix"></div>
{{result1}}
<div xn-multiple-select-tree type="text" ng-model="result1" select-data="sourceList" add-data="addResulit" name="result"></div>
</div>
</div>
</body>
<script type="text/javascript" src="../spm_modules/jquery/1.7.2/jquery.js"></script>
<script type="text/javascript" src="../spm_modules/xn-angular/1.0.0/angular.js"></script>
<script type="text/javascript" src="../spm_modules/angular-ui/1.2.0/bootstraptpls.js"></script>
<script type="text/javascript" src="../directive/selects.js"></script>
<script type="text/javascript">
angular.module("myApp", ["xn.directive.select"])
.controller("MyController", ["$scope","$timeout","$sce", function($scope,$timeout,$sce){
/*树单选*/
$timeout(function () {
$scope.source1List = [];
$scope.source1List.push({name:"你好", id:1});
$scope.source1List.push({name:"是谁", id:2});
$scope.source1List.push({name:"你是信", id:3});
$scope.source1List.push({name:"王响", id:4, parentId:3});
$scope.source1List.push({name:"王响1", id:5, parentId:4});
$scope.source1List.push({name:"王响2", id:6, parentId:4});
$scope.source1List.push({name:"王响3", id:7, parentId:3});
$scope.source1List.push({name:"王响4", id:8, parentId:1});
},1000);
$scope.selectMethod=function (data) {
console.log(data);
$scope.addResulit=angular.copy(data)
}
$timeout(function () {
$scope.sourceList = [];
$scope.sourceList.push({name:"你好", id:1});
$scope.sourceList.push({name:"是谁", id:2});
$scope.sourceList.push({name:"你是信", id:3});
$scope.sourceList.push({name:"王响", id:4, parentId:3});
$scope.sourceList.push({name:"王响1", id:5, parentId:4});
$scope.sourceList.push({name:"王响2", id:6, parentId:4});
$scope.sourceList.push({name:"王响3", id:7, parentId:3});
$scope.sourceList.push({name:"王响4", id:8, parentId:1});
},1000);
$timeout(function () {
$scope.result1 = [];
$scope.result1.push({name:"是谁", id:2});
},2000);
}]);
</script>
</html>