michaelbromley / ngx-pagination

Pagination for Angular
http://michaelbromley.github.io/ngx-pagination/
MIT License
1.23k stars 244 forks source link

Too much recursion. Need to set id for custom template #197

Closed tobiasetter closed 6 years ago

tobiasetter commented 7 years ago

Angular version: 4.2.4

ngx-pagination version: 3.0.1

Description of issue: I cannot set Id for a custom template. Therefore I cannot get multiple paginations to work. I always get the error: Too much recursion

Steps to reproduce: Place pagination-template in *ngFor

Expected result: Paginate working for multiple search pages

Actual result: Too much recursion. Works for 1.st page, for others dont.

Tried to do it with id param:

<*ngFor="let result of platform.searchResults | paginate: { itemsPerPage: 10, currentPage: page[num], totalItems: 50, id: num }">...</div>
<pagination-template #p="paginationApi" [id]="num">...</pagination-template>

and also tried without id param:

<div *ngFor="let result of platform.searchResults | paginate: { itemsPerPage: 10, currentPage: page[num], totalItems: 50 }">...</div>
<pagination-template #p="paginationApi">...</pagination-template>
michaelbromley commented 7 years ago

Hi,

Never heard of this error before. One thing I see is that it looks like you are using a number as the id. I suspect this may cause issues, if Angular is expecting the id to be a valid JavaScript identifier (i.e. cannot start with a number). Try using an id like id: '_' + num and see if that fixes it.