Zoro
Zoro

Reputation: 23

Mat sort is not applied in mat table

I have applied mat-sort looking into amswers from stack overflow,but i am not able to apply it properly.Please help Here is the stackblitz example of my code https://stackblitz.com/edit/notification.component.ts

Upvotes: 0

Views: 296

Answers (1)

atiyar
atiyar

Reputation: 8326

You need to assign the MatSort view child to the sort property of the table's data source, once the view child is initialized.

Add the following method in your component class -

ngAfterViewInit(): void {
    this.dataSource.sort = this.sort;
}

Upvotes: 1

Related Questions