Reputation: 1623
I using Angular 4 and Typescript with library ngx-pagination. I a bit don't understand this library. I have paggination in Java and I want to send page number when page is changed. Numbers of all items came from Java site. I don't know how to handle this problem. I created this code: In html:
<tr *ngFor="let story of stories | paginate: { itemsPerPage: this.size, currentPage: this.page, totalItems: this.numberOfElements }" style="text-align: left; word-break: break-all;">
<pagination-controls (pageChange)="pageChange.emit($event)"></pagination-controls>
and in TS I created this:
@Output() pageChange: EventEmitter<number> = new EventEmitter();
And now how to get page when I change it e.g. when I click on next or Previous?
Upvotes: 0
Views: 15422
Reputation: 19622
Have this in the template
<pagination-controls (pageChange)="page = $event"></pagination-controls>
and in the component have a class level variable just denoting the page like page: number = 1;
.
UPDATE
you can use this in template (pageChange)="pageChanged($event)"
in component
pageChanged(event){console.log("pageChanged")}
Upvotes: 3