Как мне сохранить номера $ index такими, как они есть в данных моего списка после нумерации страниц?
Допустим, data.length
равно 50 , и они начинаются с index 0 , первая страница содержит 10 элементов и заканчивается на index 9 следующий элемент на второй странице должен начинаться с index 10 и т. Д.
<script type="text/ng-template" id="custom-pagination">
<li ng-class="{disabled: noPrevious()||ngDisabled, previous: align}"
class="disabled previous">
<a class="btn btn-secondary btn-md mr-2 text-white"
ng-click="selectPage(page - 1, $event)">
<i class="fa fa-angle-left pagination-left"></i>
</a>
</li>
<li ng-class="{disabled: noNext()||ngDisabled, next: align}" class="disabled next">
<a class="btn btn-primary btn-md btn-md text-white"
ng-click="selectPage(page + 1, $event)">
<i class="fa fa-angle-right pagination-right"></i>
</a>
</li>
</script>
<ul class="unstyled inbox-pagination">
<li>
<span>
<%currentPage%>-
<% numPages %> из
<%data.length%>
</span>
</li>
<pagination class="np-btn pagination-sm float-right pagination"
uib-pager boundary-links="true" total-items="data.length"
ng-model="currentPage" items-per-page="pageSize"
template-url='custom-pagination'>
</pagination>
</ul>
<tr ng-repeat="(key, item) in data | startFrom: (currentPage - 1) * pageSize | limitTo: pageSize" class="cp"
ng-right-click="ShowContextMenu(key,item.unique_order_id)"
context="context_menu">
</tr>
app.controller(
'user.controller',
['$scope', '$filter', '$timeout', '$compile', 'csrfToken', 'sendRequest', 'toastr',
function($scope, $filter, $timeout, $compile, csrfToken, sendRequest, toastr){
$scope.pageSize = 1
$scope.currentPage = 1
// ......
}]).filter('startFrom', function() {
return function(data, start) {
// Some code goes right here ...
return data.slice(start)
}
});