简体   繁体   中英

ngx-pagination in Angular 4 without totalItems

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?

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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