-
Notifications
You must be signed in to change notification settings - Fork 0
/
test1.html
129 lines (126 loc) · 3.83 KB
/
test1.html
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<!DOCTYPE html>
<html ng-app="noteApp">
<head lang="en">
<meta charset="UTF-8">
<title>AngularJS</title>
<link rel="stylesheet" href="bootstrap-3.2/css/bootstrap.min.css"/>
<script src="angular/angular.min.js"></script>
<script>
var noteApp = angular.module("noteApp",[]);
var mainCtrl = noteApp.controller("mainCtrl",["$scope",function($scope) {
$scope.username = "zhangyi";
var _self = this;
this.helloMsg = "hello";
var goodbyeMsg = "goodbye";
_self.change = function() {
_self.helloMsg = "world";
};
_self.students = {
Zhangyi : {
age : 23,
credit : 100
},
zhangyi : {
age : 21,
credit : 91
},
wangxin : {
age : 24,
credit : 87
},
dongxiangwei : {
age : 99,
credit : 50
}
};
_self.nodes = [
{
id : 1,
points : 10
},
{
id : 2,
points : 11
},
{
id : 3,
points : 12
}
];
_self.changeNodes = function() {
_self.nodes = [
{
id : 1,
points : 100
},
{
id : 2,
points : 110
},
{
id : 3,
points : 120
}
];
};
}]);
</script>
</head>
<body ng-controller="mainCtrl as ctrl">
<div>
{{ctrl.helloMsg}}1
</div>
<div>
{{ctrl.username}}2
</div>
<div>
{{ctrl.goodbyeMsg}}3
<span ng-bind="username"></span>
</div>
<div>
<button class="btn btn-default" ng-click="ctrl.change()">change</button>
</div>
<ul>
<li ng-repeat="(key, value) in ctrl.students">
first <span ng-bind="$first"></span><br/>
middle <span ng-bind="$middle"></span><br/>
last <span ng-bind="$last"></span><br/>
index <span ng-bind="$index"></span><br/>
first <span ng-bind="$first"></span><br/>
even <span ng-bind="$even"></span><br/>
odd <span ng-bind="$odd"></span><br/>
key:<span ng-bind="key"></span><br/>
age:<span ng-bind="value.age"></span>
credit:<span ng-bind="value.credit"></span>
</li>
</ul>
<!--<ul>
<li ng-repeat="(key, value) in ctrl.nodes">
first <span ng-bind="$first"></span><br/>
middle <span ng-bind="$middle"></span><br/>
last <span ng-bind="$last"></span><br/>
index <span ng-bind="$index"></span><br/>
first <span ng-bind="$first"></span><br/>
even <span ng-bind="$even"></span><br/>
odd <span ng-bind="$odd"></span><br/>
key:<span ng-bind="key"></span><br/>
value:<span ng-bind="value.points"></span>
</li>
</ul>-->
<ul>
<li ng-repeat="node in ctrl.nodes track by node.id">
{{node.$$hashKey}}
value:<span ng-bind="node.points"></span>
</li>
</ul>
<button class="btn btn-default" ng-click="ctrl.changeNodes()">change</button>
<!--<ul>
<li ng-repeat-start="node in ctrl.nodes">
id:{{node.id}}
</li>
<li ng-repeat-end>
points:{{node.points}}
</li>
</ul>-->
</body>
</html>