2)
<!DOCTYPE html>
<html ng-app="filterApp">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body ng-controller="indexCtrl">
<input ng-model="search2" />
<select ng-model="search1">
<option value="name">name</option>
<option value="age">age</option>
</select>
<button ng-click="sort=!sort">排序</button>
<ul ng-show="search1=='name'">
<li ng-repeat="arr in arrs|filter:{name:search2}|orderBy:'name':sort">name:{{arr.name}} age:{{arr.age}}</li>
</ul>
<ul ng-show="search1=='age'">
<li ng-repeat="arr in arrs|filter:{age:search2}|orderBy:'age':sort">name:{{arr.name}} age:{{arr.age}}</li>
</ul>
</div>
</body>
<script src="js/angular.js"></script>
<script>
var app = angular.module('filterApp', []);
app.controller('indexCtrl', ['$scope', function($scope) {
$scope.arrs = [{
name: 'xie',
age: 30
}, {
name: 'lan',
age: 26
}, {
name: 'yao',
age: 26
}, {
name: 'yi',
age: 18
}, {
name: 'ming',
age: 16
}];
$scope.search1 = '';
$scope.search2 = '';
$scope.sort = true;
}])
</script>
</html>
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。