If you are using lodash
your pipe can be like this:
import { Pipe, PipeTransform } from '@angular/core';
import { orderBy } from 'lodash';
@Pipe({
name: 'orderBy'
})
export class OrderByPipe implements PipeTransform {
transform = orderBy;
}
And then you can use all the power of the method:
<li *ngFor="let product of products | orderBy: 'price': 'desc'">
{{product.name}}
</li>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…