角度分页:当记录从第一页删除时,下一页的记录不会在第一页自动重新填充

Angular Pagination: When records are deleted from first page, the records from the next page are not automatically getting refilled in the first page

本文关键字:第一页 记录 新填充 填充 一页 分页 删除      更新时间:2023-09-26

我使用了角度分页来显示记录。每个记录都有一个"分配给我"按钮。当我单击此按钮时,该特定记录将从列表中删除。这里的问题是,我每页显示10条记录。因此,当我点击3条记录的"分配给我"时,这3条记录都会被删除。理想情况下,第一页应该从第二页中提取3条记录,并填充从列表中删除的3条记录的空间。但这并没有发生。取而代之的是,只显示7条记录,删除的3条记录的空间被一个空格填满。这是代码。

//Pagination Settings
$scope.quoteCurrentPage = 1;
$scope.quoteTotalItems = 834;
$scope.maxSize = 5;
$scope.itemsPerPage = 10;
//HTML
<uib-pagination total-items="quoteTotalItems" ng-model="quoteCurrentPage" max-size="maxSize" class="pagination-sm" items-per-page="itemsPerPage" boundary-links="true" rotate="true"></uib-pagination>
<div class="panel-body" ng-repeat="quote in quotes.slice(((quoteCurrentPage-1)*itemsPerPage), ((quoteCurrentPage)*itemsPerPage))">
........
</div>

有人能帮忙吗?

使用splice从数组中删除项。试试看:

$scope.removeQuote = function(quote) { 
   var index = $scope.qoute.indexOf(quote);
   $scope.quotes.splice(index, 1);     
}