-
Notifications
You must be signed in to change notification settings - Fork 26
/
table点击排序angular实现.html
60 lines (56 loc) · 1.6 KB
/
table点击排序angular实现.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
<!DOCTYPE html>
<html ng-app>
<head>
<meta charset=utf-8>
<title>demo</title>
<style type="text/css">
</style>
<script src="js/angular.min.js"></script>
</head>
<body ng-controller="controller">
<table border="2px" cellspacing="0" cellpadding="0">
<tr class="header">
<th><span ng-click = "predicate='pname';reverse=true">姓名</span></th>
<th><span ng-click = "predicate='friends';reverse=!reverse">朋友数</span></th>
<th><span ng-click = "predicate='photos';reverse=!reverse">照片数</span></th>
<th><span ng-click = "predicate='weibo';reverse=!reverse">微博条数</span></th>
</tr>
<tr ng-repeat="o in obj|orderBy:predicate:reverse">
<td>{{o.pname}}</td>
<td>{{o.friends}}</td>
<td>{{o.photos}}</td>
<td>{{o.weibo}}</td>
</tr>
</table>
<script>
function controller($scope){
$scope.obj = [
{
'pname' : '大额',
'friends': 38,
'photos': 45,
'weibo': 123
},
{
'pname' : 'Pan',
'friends': 32,
'photos': 86,
'weibo' : 39
},
{
'pname' : '搞笑排行',
'friends': 63,
'photos': 76,
'weibo' : 98
},
{
'pname' : 'News',
'friends': 43,
'photos': 49,
'weibo' : 356
}
];
}
</script>
</body>
</html>