分页在AngularJS智能表中不起作用

时间:2018-08-30 10:47:11

标签: javascript angularjs smart-table

表对于第一个API调用工作正常,但是由于某些原因,页数没有变化:

GetFileDetails($scope.fileNameForDetails).then(function(fileDetail)用于API调用以获取数组列表,然后使用智能表并通过分页将其显示在表上。

$scope.fileDetailsForTable = function(tableState) {
  $scope.paginationControl = '';
  var pagination = tableState.pagination;
  if (pagination.number) {
    pageNo = (pagination.start / pagination.number) + 1;
  } else {
    pageNo = pagination.start + 1;
  }
  if ($scope.fileNameForDetails) {
    var requestData = {};
    requestData = {
      'fileName': $scope.fileNameForDetails,
      'pageNumber': pageNo,
      'pageSize': '10'
    }
    store.set('BULK_FILE_REQUEST_DATA', requestData);
    $scope.paginationControl = false;
    GetFileDetails($scope.fileNameForDetails).then(function(fileDetail) {

      $scope.fileDetailsData = fileDetail;
      $scope.fileDetails = $scope.fileDetailsData.data;
      $scope.totalRecordsFound = $scope.fileDetailsData.totalRecords;
      if ($scope.totalRecordsFound > 0) {
        tableState.pagination.numberOfPages = getNumberOfPages($scope.totalRecordsFound);
        $scope.pagesss = tableState.pagination.numberOfPages;
        $scope.paginationControl = true;
      }
    });

    function getNumberOfPages(totalRecordsCount) {
      return Math.ceil(totalRecordsCount / 10) || 1;

    }
  }
};

0 个答案:

没有答案