orderBy: '-name' 遞減
orderBy: '+name' 遞增
orderBy: '-name':true 遞增
orderBy: '-name':false 遞減
<script src="~/Scripts/ngcontroller.js"></script>
<div ng-app="myModule">
<div ng-controller="myController">
<table border="1">
<thead>
<tr>
<th>name</th>
<th>dateofBirth</th>
<th>gender</th>
<th>salary</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="a in employees | orderBy: '-name':true">
<td>{{a.name }}</td>
<td>{{a.dateofBirth | date:"yyyy/MM/dd" }}</td>
<td>{{a.gender }}</td>
<td>{{a.salary }}</td>
</tr>
</tbody>
</table>
</div>
</div>
ngcontroller.js
var myApp = angular.module("myModule", []);
myApp.controller("myController", function ($scope) {
var employees = [{
name: "Ben", dateofBirth: new Date("November 23 1980")
, gender: "Male", salary: 55000.788
}
, {
name: "Ben", dateofBirth: new Date("November 23 1980")
, gender: "Male", salary: 55000.788
}
, {
name: "Sara", dateofBirth: new Date("May 05 1970")
, gender: "FeMale", salary: 68000
}
, {
name: "Mark", dateofBirth: new Date("August 15 1974")
, gender: "Male", salary: 57000
}
, {
name: "Pam", dateofBirth: new Date("October 27 1979")
, gender: "FeMale", salary: 53000
}];
$scope.employees = employees;
$scope.limitRows = 3;
});