Reputation: 1301
I have a paginate layer showing the results to ten a ten:
<div class="panel-body" ng-repeat="user in users">
<div class="col-md-12">
<div class="col-md-6 name">{{user.dato1}}</div>
<div class="col-md-6 product">{{user.dato2}}/div>
</div>
<div class="col-md-12 pos-action">
<div class="col-md-4 product">{{user.dato3}}</div>
<div class="col-md-8 product">{{user.dato4}}</div>
</div>
</div>
I need the following: The first page show ten results, but if I go to the next page I have to show the new ten results and the ten the previous results and so on, for example, the page size three must have thirty registers, but if I come back the page size one must show only ten.
/*
* Function to get data service.
*/
function paintData()
{
dataIn=getListEventsPdtes.dataIn;
dataOut=getListEventsPdtes.dataOut;
if(dataOut.listEvents != null ){
$scope.users = dataOut.listEvents.event;
//Save data in cache
$scope.cache=$scope.cache.concat(dataOut.listEvents.event);
}else{
var text = "An internal error occurred, please contact your system administrator";
modalFactory.message(text);
}
}
function prevPage(){
if($scope.currentPage > 0){
$scope.currentPage--;
var cachedValues = $scope.cache.slice($scope.currentPage*$scope.itemsPerPage, $scope.currentPage*$scope.itemsPerPage+$scope.itemsPerPage);
$scope.users = cachedValues;
}
};
function nextPage(dato, repo){
$scope.currentPage++;
var cachedValues = $scope.cache.slice($scope.currentPage*$scope.itemsPerPage, $scope.currentPage*$scope.itemsPerPage+$scope.itemsPerPage);
if(cachedValues.length == 0){
$scope.getData(dato, repo);
}else{
$scope.users = cachedValues;
}
};
Thanks,
Upvotes: 0
Views: 45
Reputation: 111
Can u pass the index value to PrevPage when click on paging index 1 2....
function prevPage(index){
if($scope.currentPage > 0){
$scope.currentPage--;
var cachedValues = $scope.cache.slice(index*$scope.itemsPerPage, index*$scope.itemsPerPage+$scope.itemsPerPage);
$scope.users = cachedValues;
}
};
Upvotes: 1