I am facing this issue if i am adding ngx-paginator to mat table. Please help me out.
<table mat-table [dataSource]="dataSource| paginate: {itemsPerPage: size, currentPage: p,
totalItems: EMP_DATA.length}" class="mat-elevation-z8" matSort>
.
.
<pagination-controls (pageChange)="p = $event;paginate(p)"
[responsive]="true"
></pagination-controls>
IN ts file
size = 10;
pageIndex = 0;
p=1;
dataSource = new MatTableDataSource<EmpElement>(this.EMP_DATA);
paginate(event: any) {
this.pageIndex=event;
}
From the error, I am assuming that EmpElement is not an array
Change below line:
dataSource = new MatTableDataSource<EmpElement[]>(this.EMP_DATA);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.