I have a Angular2
app with a component
where I have a table.
Table is generated via *ngFor
directive.
Each row of the table
it's my working solution. API for ngb-pagination: https://ng-bootstrap.github.io/#/components/pagination
...
In your component you need some like that. Don't forget set your variable in constructor:
itemsPerPage: number;
totalItems: any;
page: any;
previousPage: any;
...
loadPage(page: number) {
if (page !== this.previousPage) {
this.previousPage = page;
this.loadData();
}
}
...
loadData() {
this.dataService.query({
page: this.page - 1,
size: this.itemsPerPage,
}).subscribe(
(res: Response) => this.onSuccess(res.json(), res.headers),
(res: Response) => this.onError(res.json())
)
}