我有如下设置orderByField
andreverseSort
变量的表头:
<th class='header'>
<a href="" ng-click="orderByField='success'; reverseSort = !reverseSort">
Successes <span ng-show="orderByField == 'success'"><span ng-show="!reverseSort"
class="glyphicon glyphicon-chevron-up"></span><span ng-show="reverseSort" class="glyphicon glyphicon-chevron-down"></span></span>
</a>
</th>
我有一个 ng 重复:
<tbody>
<tr ng-repeat="item in items| filter:paginate |orderBy:sorter:reverseSort">
<td>{{item.name}}</td>
<td>{{item.failPercentage}}</td>
<td>{{item.failure}}</td>
<td>{{item.success}}</td>
</tr>
</tbody>
我也为此使用该ui.bootstrap
库:
<uib-pagination total-items="totalItems"
ng-model="currentPage"
max-size="15" boundary-links="true"
items-per-page="numPerPage" class="pagination-sm">
</uib-pagination>
在我的控制器中,我有一个paginate
功能和sorter
功能适用于我的ng-repeat
$scope.paginate = function (value) {
var begin, end, index;
begin = ($scope.currentPage - 1) * $scope.numPerPage;
end = begin + $scope.numPerPage;
index = $scope.items.indexOf(value);
return (begin <= index && index < end);
};
$scope.sorter = function (item) {
return item[$scope.orderByField];
};
我的排序只使用默认排序,但是当我排序时,它对每个页面进行独立排序。我如何将排序应用于相互依赖的所有页面(然后将用户发送到分页的第一页)?