1
I have a pagination OD and I want him to do an item count, ex: has 40 items and I want to read in 5 per pages, then the first page reads 1 of 5, the second and 6 of 10 and the third and 11 of 15 and so on, my Cod does it, only q the last page if you have example, only two items he continues to make the account as if he had with 5, I’ll pass the code part so you can help me:
$http({
method: 'GET',
url: '/user/distrito?page=' + $scope.page + '&size=' + size
}).then(function(response) {
$scope.distritos = response.data.content;
$scope.number = response.data.number;
$scope.totalDePaginas = response.data.totalPages;
$scope.dados2 = response.data.totalElements;
$scope.primeiraPagina = response.data.first;
$scope.ultimaPagina = response.data.last;
$scope.numeroElementos = response.data.numberOfElements;
$scope.size = response.data.size;
if (size > $scope.dados2) {
$(".proximo").prop("disabled", true);
}
if ($scope.ultimaPagina == true) {
$(".proximo").prop("disabled", true);
$(".anterior").prop("disabled", false);
} else {
$(".anterior").prop("disabled", false);
}
/* if($scope.ultimaPagina == false){
$("#proximo").prop("disabled",false);
}*/
$('.numeracaoUni').text(($scope.number + 1));
* * $('.numeracao').text(' ' + (($scope.size) * $scope.number + 1) + ' - ' + $scope.numeroElementos * ($scope.number + 1)); * *
$('.registros').text(' de ' + $scope.totalDePaginas + ' ');
});
In bold and the part that does this, in case it does the normal account until the last page because it’s multiplying by the size only q not and that q want to have to give the right result at the end. Who can help me I thank.
It wasn’t very clear to me, but if I understand correctly, try to exchange $Scope.size for $Scope.data2 (which I understand is the total of elements that you actually want to display).
– GustavoAdolfo
is I want it to add up as you change pages, according to your items.has 40 items and I want to read in 5 by pages, then the first page reads 1 of 5, the second and 6 of 10 and the third and 11 of 15 and so on
– Diego Laura Soares