[英]angular 2 material paginator get current page index
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. 我使用角度为2的材料设计。我想在我的应用程序中使用材质设计分页器,并在组件中获取当前选定的页面索引。 There is not much documentation for the paginator plugin.here is the material paginator page: https://material.angular.io/components/paginator/overview paginator插件没有太多文档。这是材料分页器页面: https : //material.angular.io/components/paginator/overview
html Code HTML代码
<md-paginator [length]="100"
[pageSize]="10"
[pageSizeOptions]="[5, 10, 25, 100]">
</md-paginator>
angular 2 code 角2代码
@Component({
selector: 'paginator-overview-example',
templateUrl: 'paginator-overview-example.html',
})
export class PaginatorOverviewExample {
//I want to get page change event here
}
You can get the current page index by using the page
Output event. 您可以通过使用获得当前页面的索引page
输出的事件。 The $event
from page
returns three pieces of information: 来自page
的$event
返回三条信息:
html: HTML:
<md-paginator [length]="length"
[pageSize]="pageSize"
[pageSizeOptions]="pageSizeOptions"
(page)="onPaginateChange($event)">
</md-paginator>
ts: TS:
onPaginateChange(event){
alert(JSON.stringify("Current page index: " + event.pageIndex));
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.