I have 3 mat table in single component and i am loading its data on page load. Issue is with less that 500(for all 3 tables) records also it is taking 8-10 seconds of time to load data
<div id="div1"
[hidden]="!( div1===1 && div2===0 && div3===0)">
<table mat-table [dataSource]="dataSource1" matSort>
/////table 1
</table>
<mat-paginator [pageSizeOptions]="[5, 10, 25, 100]"></mat-paginator>
</div>
<div id="div2"
[hidden]="!( div1===0 && div2===1 && div3===0)">
<table mat-table [dataSource]="dataSource2" matSort>
/////table 2
</table>
<mat-paginator [pageSizeOptions]="[5, 10, 25, 100]"></mat-paginator>
</div>
<div id="div3"
[hidden]="!( div1===0 && div2===0 && div3===1)">
<table mat-table [dataSource]="dataSource3" matSort>
/////table 3
</table>
<mat-paginator [pageSizeOptions]="[5, 10, 25, 100]"></mat-paginator>
</div>
My TS file is
export class mycomponent implements OnInit {
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
@ViewChild(MatSort, { static: true }) sort: MatSort;
constructor(private _servcall: AppService) {
}
ngOnInit() {
this._servcall.getdatafromapi().subscribe(result => {
this.resultdata = result;
this.displayedColumns = ['col1','col2']
this.dataSource1 = new MatTableDataSource(this.resultdata);
this.dataSource1.paginator = this.paginator;
this.dataSource1.sort = this.sort;
this.displayedColumns = ['col1','col2']
this.dataSource2 = new MatTableDataSource(this.resultdata);
this.dataSource2.paginator = this.paginator;
this.dataSource2.sort = this.sort;
this.displayedColumns = ['col1','col2']
this.dataSource2 = new MatTableDataSource(this.resultdata);
this.dataSource2.paginator = this.paginator;
this.dataSource2.sort = this.sort;
}
})
}
}
I have tried solution from link but still issue is same. Code which is there on page load I call same during some tab change , during that time also it is slow