Angular2 Order Pipe
Order your collection by a field
Demo page
https://vadimdez.github.io/ng2-order-pipe/
Install
npm install ng2-order-pipe --save
Usage
In HTML template
{{ collection | orderBy: expression : reverse }}
Arguments
Param | Type | Details |
---|---|---|
collection | array or object |
The collection or object to sort |
expression | string |
The key to determinate order |
reverse (optional) | boolean |
Reverse sorting order |
Import Ng2OrderModule
to your module
;;; ;
And use pipe in your component
;
Deep sorting
Use comma separated path for deep properties when passing object.
{{ { prop: { list: [3, 2, 1] } } | orderBy: 'prop.list' | json }}
Result:
{ prop: { list: [1, 2, 3] } }