filter排序
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body ng-app="app" ng-controller="xmgController">
<p>{{score | orderBy:'' :true}}</p>
<hr>
<!--
第一個參數(shù): 對哪個字段排序
第二個參數(shù): true:降序, false:升序-->
<p>{{stu | orderBy:'age' : false}}</p>
</body>
<script src="js/angular.js"></script>
<script>
//1.創(chuàng)建模塊
var app = angular.module('app', []);
//2.創(chuàng)建控制器
app.controller('xmgController', ['$scope', function ($scope) {
$scope.score = [55, 22, 44, 11, 33];
$scope.stu = [
{name:'zs', age:18},
{name:'ls', age:22},
{name:'yj', age:11},
{name:'sk', age:33}
];
}]);
//3.綁定模塊 ng-app="app"
//4.綁定控制器 ng-controller="xmgController"
</script>
</html>
最后編輯于 :
?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者