Hi, nice article!
To avoid to call setTimeout() function inside your ngOnInit() method, you can to use the ngAfterViewInit() method.
ngAfterViewInit() {
this.dataSource.sort = this.sort;
this.dataSource.sortingDataAccessor = (item, property) => {
return item[property].toLocaleLowerCase();
};
}
According to documentation, Angular guarantees that your @ViewChild will be set before ngAfterViewInit() is called.
Hi, nice article!
To avoid to call
setTimeout()function inside yourngOnInit()method, you can to use thengAfterViewInit()method.ngAfterViewInit() { this.dataSource.sort = this.sort; this.dataSource.sortingDataAccessor = (item, property) => { return item[property].toLocaleLowerCase(); }; }According to documentation, Angular guarantees that your
@ViewChildwill be set beforengAfterViewInit()is called.