Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

order by ascending descending in angular 6 on click of button

private isAscendingSort: boolean = false;

sortUser() {
  console.log('sorting!'); // just to check if sorting is being called
  this.isAscendingSort = !this.isAscendingSort; // you missed this

  this.items.sort((item1: any, item2: any) => this.compare(item1, item2));
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #order #ascending #descending #angular #click #button
ADD COMMENT
Topic
Name
5+4 =