angular 2 material paginator get current page index
11,905
You can get the current page index by using the page
Output event. The $event
from page
returns three pieces of information:
- pageIndex
- pageSize
- length
html:
<md-paginator [length]="length"
[pageSize]="pageSize"
[pageSizeOptions]="pageSizeOptions"
(page)="onPaginateChange($event)">
</md-paginator>
ts:
onPaginateChange(event){
alert(JSON.stringify("Current page index: " + event.pageIndex));
}
Author by
Manoj Sanjeewa
I am web and mobile application developer specialize in android, PHP , Nodejs and angularJS.
Updated on June 04, 2022Comments
-
Manoj Sanjeewa almost 2 years
I'am using material design with angular 2. I want to use material design paginator for my application and get the current selected page index in the component. There is not much documentation for the paginator plugin.here is the material paginator page: https://material.angular.io/components/paginator/overview
html Code
<md-paginator [length]="100" [pageSize]="10" [pageSizeOptions]="[5, 10, 25, 100]"> </md-paginator>
angular 2 code
@Component({ selector: 'paginator-overview-example', templateUrl: 'paginator-overview-example.html', }) export class PaginatorOverviewExample { //I want to get page change event here }