您看到数据已正确呈现,但每页的项目未定义加上搜索输入类型宽度缩小但如果我重新加载页面正确,怎么会?为什么当我访问此页面以及刷新数据时这种有线行为正确呈现
打字稿文件的代码 -
.ts
length;
pageSize = 25;
pageSizeOptions = [25, 50, 75, 100];
@ViewChild('TABLE') table: ElementRef;
@ViewChild(MatPaginator) paginator: MatPaginator;
ngOnInit() {
this.adminservice.getClearedStudents();
this.studentSub = this.adminservice.getClearedStudentsListener().subscribe(result => {
if (result.length > 0) {
// tslint:disable-next-line: prefer-for-of
for (let i = 0; i < result.length; i++) {
result[i].registrationno = '[ ' + result[i].registrationno + ' ]' ;
}
this.dataSource = new MatTableDataSource(result);
this.dataSource.paginator = this.paginator;
this.length = result.length;
}
});
}
和 html 文件代码 -
<mat-paginator [length]="length" [pageSize]="pageSize" [pageSizeOptions]="pageSizeOptions" showFirstLastButtons></mat-paginator>
只是为了让您知道带有此类表格的其他页面,垫子分页器效果很好,只有这个困扰着我,感谢您的帮助,提前谢谢...