Angular Material Table - custom Sort
1. Overview
Angular Material is most often useful and saves you work a lot building directives and components from scratch, but sometimes we need a little more control over behaviors and events. In this article we'll learn how we can do a custom sort...
alina-olaru.hashnode.dev9 min read
Wellington Domiciano
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.