ngx-pagination in Angular 4 without totalItems

2.4k Views Asked by At

I'm relying on a REST service that allows for pagination, ex: http://10.127.2.20:23700/v1/telname?filterCriteria.pageSize=25&filterCriteria.pageNumber=1

If you don't provide these values then the default is usually pageSize 25 and pageNumber 1.

Now I am building an Angular4 app to consume this service and am running into a problem where I don't have access to the metadata required to populate totalItems in my ngFor:

<tr *ngFor='let telName of telNames | telNameFilter:listFilter | paginate: { itemsPerPage: items, currentPage: page, totalItems: total }'> 

I'm using @angular/core 4.4.6 and ngx-pagination 3.0.3

At the moment i am hard coding total in my list component, but I would like to know if it's possible to change how pagination works in this module I installed.. can I provide an infinite # for total so that the user can just keep clicking Next for inifinite or at least until there are no values left in the page they ask for?

Or could I alter the <pagination-controls (pageChange)="getPage($event)"></pagination-controls> behavior so that instead of a list of numbers, perhaps there is a single textbox that shows the current page and the next/prev buttons merely change that value from 0 to whatever is in the textbox?

1

There are 1 best solutions below

0
On

If you don't use totalItems attribute of Ngx-pagination it will take length of the array provided i.e. in your case telNames. i.e.

<tr *ngFor='let telName of telNames | telNameFilter:listFilter | paginate: { itemsPerPage: items, currentPage: page }'>