I am looking to populate this model
oldDataSource: Array<any> = [];
with the values from the datasource.
This is the code I have tried:
ngOnInit(): void {
this.dataSourceInit();
}
dataSourceInit(): void {
this.dataSource = new DefaultScoreCoinDataSource(this.defaultScorService);
this.dataSource.loadDefaultScoreCoins(1, this.pageSize, this.filters);
}
private loadDataSource(): void {
this.dataSource.loadDefaultScoreCoins(
this.paginator.pageIndex + 1,
this.paginator.pageSize,
this.filters
);
}
ngAfterViewInit(): void {
this.oldDataSource = this.dataSource['defualtScoreSubject'].value;
}
However, this approach did not work for me as it did not populate this.oldDataSource
. The issue arises when running ngAfterViewInit
, as the datasource may take some time to fetch data from the server. Therefore, this.oldDataSource
remains null until the data is retrieved.
Is there a way to effectively populate this.oldDataSource
with the values from the datasource?