繁体   English   中英

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

[英]How to increment serial number while using pagination in Angular.js

我需要一个帮助。我正在使用 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....一样继续1,2,3....等等。请帮我解决这个问题。

可以使用(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>

控制器:

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

示例Plunker 演示

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM