我有一个<mat-paginator>
在 *.component.html 中,其属性定义如下:
<mat-paginator #paginator
[pageSize]="10"
[pageSizeOptions]="[5, 10, 20]"
(page)="onPaginateChange($event)">
</mat-paginator>
是否可以得到该属性(property)pageSize
进入我的 *.component.ts?
尝试引用原生 html 元素,但没有用
谢谢!
最佳答案
我认为您可以通过 @ViewChild
装饰器获取 mat-paginator
并尝试在 ngAfterViewInit
生命周期事件 Hook 中访问它。
@ViewChild('paginator') paginator;
ngAfterViewInit() {
console.log(this.paginator.pageSize)
}
也在查看documentation时它在 page
事件中为您提供 pageSize
PageEvent Change event object that is emitted when the user selects a different page size or navigates to another page.
pageSize: number - The current page size
关于angular - 如何将 HTML 的属性输入到 typescript 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52152941/