gpt4 book ai didi

javascript - 如何在 Angular.js 中使用分页时增加序列号

转载 作者:行者123 更新时间:2023-11-30 07:02:05 24 4
gpt4 key购买 nike

我需要一个帮助。我正在使用 Angular.js dirPagination.js 对我的表格数据进行分页,但我的问题是假设我每页固定的项目是 5,前 5 个项目即将到来序列号 1,2,3,4,5 但对于第二页,序列号再次从 1 开始。我在下面添加我的代码。

<tr dir-paginate="pro in ($parent.labelResults=(productDataList  | filter:searchProduct)) | itemsPerPage:5" current-page="currentPage">
<td>{{itemsPerPage *(currentPage-1)+$index+1}}</td>
<td>{{pro.Product_name}}</td>
<td><img ng-src="upload/{{pro.image}}" name="pro" border="0" style="width:50px; height:50px; border:#808080 1px solid;" /></td>
<td>{{pro.Discount}}</td>
<td>{{pro.Offer}}</td>
<td>{{pro.unit_cost_price}}</td>
<td>{{pro.unit_sale_price}}</td>
<td>{{pro.quantity}}</td>
<td>{{pro.shipping_charge}}</td>
</tr>
<div class="pull-right">
<dir-pagination-controls max-size="5" direction-links="true" boundary-links="true" >
</dir-pagination-controls>
</div>

在这里,对于分页的每一页,序列号从 1 开始。这里我需要从第一页开始,序列号应该从 1 开始,并且它应该继续像 1,2,3....等等。请帮我解决这个问题。

最佳答案

Could be achieved using (ITEMS_PER_PAGE * (CURRENT_PAGE-1)) + $index+1

<tr dir-paginate="pro in users | itemsPerPage:itemsPerPage" current-page="currentPage"> 
<td>{{itemsPerPage *(currentPage-1)+$index+1}}</td>
<td>{{pro.first_name}}</td>
<td>{{pro.last_name}}</td>
<td>{{pro.hobby}}</td>
</tr>

Controller :

$scope.currentPage=1;
$scope.itemsPerPage=5;

样本 Plunker demo

关于javascript - 如何在 Angular.js 中使用分页时增加序列号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36255899/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com