I'm trying to code pagination using NgxPagination. But I don't know how to pass pageIndex from component to service. It only display one page only. And can't go to next page.image reference
I provided code bellow for your reference.
HTML
<ng-container
matColumnDef="{{ column }}"
*ngFor="let column of columnsToDisplay | paginate: { id: 'server',
itemsPerPage: 10, currentPage: p, totalItems: total }"
>... </ng-container>
<pagination-controls (pageChange)="loadData($event)" id="server"></pagination-controls>
Component ts
length:number;
pageIndex :number;
p: number = 1;
total: number;
loadData(pageIndex){
this.listservice.getListService(pageIndex).subscribe(res =>{
this.dataSource = new MatTableDataSource<ListDetails>(res);
this.total = res.total;
this.p = pageIndex;
}
And in my service code I make like bellow
service
getListService(page:number): Observable<any> {
const urls: string = `http://192.168.0.101:9080/projek/api/listall/${Id}`
const rUrl: string = `${urls}/${page + 1}/desc`;
return this.http.get<AllDetails>(rUrl).pipe(map(res => res['allList']));
}
What should I add to make it work.
Hope you all can help me
Thanks in advance.