Last active
November 5, 2019 10:28
-
-
Save finki001/0f485c1fb74f94c142536090725654b3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Pipe({ | |
name: "sortDescending" | |
}) | |
export class SortDescendingPipe implements PipeTransform { | |
transform(list: any[], ...args: any[]): any[] { | |
return list.slice().sort((elem1, elem2) => elem2.rollNo - elem1.rollNo); | |
} | |
} | |
// use it in your template like this: | |
{{ todo | sortDescending }} to display it or like <div *ngFor="let singleTodo of todo | sortDescending">…</div> to iterate over the descending array |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment