最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to increment serial number while using pagination in Angular.js - Stack Overflow

programmeradmin5浏览0评论

I need one help .i am using Angular.js dirPagination.jsfor pagination of my table data but here my problem is suppose i fixed item per page is 5,the first 5 items is ing with serial no 1,2,3,4,5 but for second page again the serial no is starting from 1.I am adding my code below.

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

Here for each page of pagination the serial no is starting from 1.Here i need from the first page the serial no should starts from 1 and it should continue like 1,2,3....so on.Please help me to resolve this issue.

I need one help .i am using Angular.js dirPagination.jsfor pagination of my table data but here my problem is suppose i fixed item per page is 5,the first 5 items is ing with serial no 1,2,3,4,5 but for second page again the serial no is starting from 1.I am adding my code below.

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

Here for each page of pagination the serial no is starting from 1.Here i need from the first page the serial no should starts from 1 and it should continue like 1,2,3....so on.Please help me to resolve this issue.

Share Improve this question edited Mar 28, 2016 at 5:17 satya asked Mar 28, 2016 at 4:17 satyasatya 3,56011 gold badges57 silver badges134 bronze badges 13
  • Consider Page Number as well... – Rayon Commented Mar 28, 2016 at 4:18
  • @RayonDabre: not getting you.Can you please give any solution? – satya Commented Mar 28, 2016 at 4:23
  • If I read you right, If there are 5 items in each page and 10 items in total, you expect 6,7,8.. in the next page right ? – Rayon Commented Mar 28, 2016 at 4:24
  • It could be achieved using (ITEMS_PER_PAGE * (CURRENT_PAGE-1)) + $index+1 – Rayon Commented Mar 28, 2016 at 4:32
  • Where i will write this.Can you edit your answer in my code please? – satya Commented Mar 28, 2016 at 4:35
 |  Show 8 more ments

1 Answer 1

Reset to default 18

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;

Sample Plunker demo

发布评论

评论列表(0)

  1. 暂无评论