console
var app = angular.module('app', []);
app.controller('controller', ['$scope', function($scope) {
$scope.data = [{
name: "张明明",
sex: '男',
age: 24,
score: 95
},
{
name: "李潇潇",
sex: '女',
age: 34,
score: 85
},
{
name: "何侃",
sex: '男',
age: 20,
score: 75
},
{
name: "汪先生",
sex: '男',
age: 14,
score: 90
},
{
name: "陈莎莎",
sex: '女',
age: 28,
score: 65
}];
$scope.findscore = function(e) {
return e.score > 80
}
}])
app.filter('young',function(){
return function(e,type){
var _out = [];
var _sex = type?'男':'女';
for(var i=0;i<e.length;i++){
if(e[i].age>22 && e[i].age<28 && e[i].sex == _sex){
_out.push(e[i]);
}
}
return _out;
}
})
<!DOCTYPE html>
<html lang="en" ng-app="app">
<head>
<meta charset="UTF-8" />
<title>
Document
</title>
<script src="https://cdn.bootcss.com/angular.js/1.6.4/angular.min.js">
</script>
</head>
<body ng-controller="controller">
<table border="1">
<tr>
<th>
序号
</th>
<th>
姓名
</th>
<th>
性别
</th>
<th>
年龄
</th>
<th>
成绩
</th>
</tr>
<tr ng-repeat="stu in data | orderBy: '-score' | limitTo: 3 | filter: findscore">
<td>
{{$index+1}}
</td>
<td>
{{stu.name}}
</td>
<td>
{{stu.sex}}
</td>
<td>
{{stu.age}}
</td>
<td>
{{stu.score}}
</td>
</tr>
</table>
</body>
</html>