Angularjs - 累积分页结果

时间:2016-12-16 12:04:55

标签: angularjs

我有一个分页图层,显示十分之十的结果:

<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>

我需要以下内容:第一页显示十个结果,但如果我转到下一页,我必须显示新的十个结果和十个以前的结果等等,例如,页面大小三必须有三十个寄存器,但如果我回来,页面大小必须只显示十个。

/*
 * 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,

1 个答案:

答案 0 :(得分:1)

点击分页索引1 2 ....

可以将索引值传递给PrevPage
TABLE_TRUCK_DETAIL_MASTER_DATA

};