<!DOCTYPE html>
<html>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body>
<p>Click the table headers to change the sorting order:</p>
<div ng-app="myApp" ng-controller="namesCtrl">
<table border="1" width="100%">
<tr>
<th ng-click="orderByMe('name')">Name</th>
<th ng-click="orderByMe('country')">Country</th>
<th ng-click="orderByMe('newIndex')">Index</th>
</tr>
<tr ng-repeat="x in names | orderBy:myOrderBy:true" ng-init="x.newIndex = $index">
<td>{{x.name}}</td>
<td>{{x.country}}</td>
<td>{{x.newIndex}}</td>
</tr>
</table>
</div>
<script>
angular.module('myApp', []).controller('namesCtrl', function($scope) {
$scope.names = [
{name:'Jani',country:'Norway'},
{name:'Carl',country:'Sweden'},
{name:'Margareth',country:'England'},
{name:'Hege',country:'Norway'},
{name:'Joe',country:'Denmark'},
{name:'Gustav',country:'Sweden'},
{name:'Birgit',country:'Denmark'},
{name:'Mary',country:'England'},
{name:'Kai',country:'Norway'}
];
$scope.orderByMe = function(x) {
$scope.myOrderBy = x;
}
});
</script>
</body>
</html>
感謝を助けになると思う逆に反復を説明するために単純な例ですが、私は配列のインデックスを印刷しているので、私は配列を逆にする必要はありません、私はちょうどそれらを逆にしたい配列全体orderByフィルタを使用します。これは全体的な文脈でこれを参照していましたhttp://jsfiddle.net/rvgvs2jt/2/ –