I am trying to have sorting on table header. I am able to utilize this https://stackblitz.com/edit/angular-sort-filter but I wanted to add arrows on click on header (asc/desc) or maybe a class to toggle which I can do it from css.
sort(property) { this.isDesc = !this.isDesc; //change the direction this.column = property; let direction = this.isDesc ? 1 : -1; this.records.sort(function (a, b) { if (a[property] < b[property]) { return -1 * direction; } else if (a[property] > b[property]) { return 1 * direction; } else { return 0; } }); }; Thanks for your help.
Happy New Year!
https://stackoverflow.com/questions/65571569/how-can-i-add-arrow-class-on-table-sort-header January 05, 2021 at 08:12AM
没有评论:
发表评论