ngx-pagination id is not working
ngx-pagination is working fine single time but when I am using multiple times pagination not working. I am also trying with id approach but the same issue.
Hi there,
I'll re-post the issue template so you have another chance to fill it out. It is in your interest to take the time to do so, as it makes it much easier for me to help you. Please reply with as much of the following filled out as you can:
=======
Angular version:
ngx-pagination version:
Description of issue:
Steps to reproduce:
Expected result:
Actual result:
Demo: (if possible, edit this StackBlitz demo and paste the link to your fork)
Any relevant code:
Angular version: 7.3.8
ngx-pagination version:4.0.0
Description of issue: ngx-pagination is not working if we use multiple times.
Steps to reproduce: you can use two times in single page .
Can you please show me the code which reproduces the error? Otherwise I cannot help.
<table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
<thead>
<tr>
<th>OrderId </th>
<th>Customer Name </th>
<th>Customer Email</th>
<th>Rider Name </th>
<th>Price</th>
<th>Restauran<br>Rating</th>
<th>Rider<br>Rating</th>
<th>createdAt</th>
</tr>
</thead>
<tfoot>
<tr>
<th>OrderId</th>
<th>Customer Name </th>
<th>Customer Email</th>
<th>Rider Name </th>
<th>Price</th>
<th>Restauran<br>Rating</th>
<th>Rider<br>Rating</th>
<th>created</th>
</tr>
</tfoot>
<tbody>
<tr *ngFor="let restaurantItem of orderListResp | paginate: { id: 'test',itemsPerPage: DefaultPageLimit, currentPage: currentPageNumber,totalItems: totalNumberOfPages }" id="tr_{{restaurantItem._id}}">
<td class="textWidth">#{{restaurantItem.orderAuoIncrement}} </td>
<td class="textWidth">{{restaurantItem.customerId.name | capitalize}} </td>
<td>{{restaurantItem.customerId.email}}</td>
<td><span *ngIf="restaurantItem.driverId && restaurantItem.driverId.firstName">
{{restaurantItem.driverId.firstName | capitalize}}</span> </td>
<td>{{restaurantItem.totalPrice | currency:'USD':true:'2.0' }}</td>
<td><span *ngIf="restaurantItem.restauranRatingGivenbyCustomer&&
restaurantItem.restauranRatingGivenbyCustomer.rating">{{restaurantItem.restauranRatingGivenbyCustomer.rating}}</span>
</td>
<td><span *ngIf="restaurantItem.riderRatingGivenbyCustomer&&
restaurantItem.riderRatingGivenbyCustomer.rating">{{restaurantItem.riderRatingGivenbyCustomer.rating}}</span>
</td>
<td class="descriptionText">{{restaurantItem.createdAt | date:'medium'}}</td>
</tr>
<tr *ngIf="orderListResp && orderListResp.length==0">
<td class="textAligncenter" colspan="8">No Data Found </td>
</tr>
</tbody>
</table>
<pagination-controls id="orderPa_1 "(pageChange)="orderListPageChange(currentPageNumber=$event)" previousLabel="" nextLabel="" >
</pagination-controls>
DefaultPageLimit:12, totalNumberOfPages:12

why it showing second-page numbers?
I think it is a conflict with other pagination on the same page
Thanks for posting the code. Small hint - surround code blocks with 3 back-ticks to get GitHub to format correctly (see here for more instructions). I did it for you this time.
So in your example I can only see a single pagination instance, with the ID "test", but then the controls component has the ID "orderPa_1". These 2 IDs are supposed to be the same in order to be linked to one another.
Also I just wanted to check whether you are doing server-side pagination? Because the code above is set up for server-side rather than client-side pagination, due to the use of the totalItems field being passed to the paginate pipe.
Thanks for replay but when i used id with pagination-controls tag following error occur .

Second example
| OrderId | Image | Item Name | Category | SubCategory |
|---|
it is working fine if I used once in a page
it is working fine if I used once on a page. you can check the output
totalItems : 12
Ok. At this point I cannot tell from the information you are providing whether there is a genuine bug here or whether your use of the library is incorrect.
I must now require you to recreate the issue by editing this StackBlitz demo with a minimal reproduction in order to help you further.
(fork the demo, reproduce the error, save and share the result back to this thread)
Hi, I just add the id in (https://stackblitz.com/edit/angular-e1f9hq) same error occurs. You can check.
(fork the demo, reproduce the error, save and share the result back to this thread)
https://stackblitz.com/edit/angular-tfee1t?file=app
Thanks for the reproduction. Please see the instructions on how to use multiple instances of pagination. Follow the instructions closely and let me know if this resolves your issue: https://github.com/michaelbromley/ngx-pagination#multiple-instances