My markup looks like this:
<li *ngFor="let user of usersList | orderBy : ['name']; let i = index;">
So is there anyway to apply orderBy pipe only when certain boolean is true?
How about something like
<li *ngFor="let user of usersList | orderBy : [value ? 'name' : '']; let i = index;">
Another option would be creating a wrapper pipe that takes a parameter and uses the orderBy pipe conditionally.
*EDIT
As @OliverRenner states, orderBy
is no longer offered by Angular in 2.0. The above assumes that you have written your own orderBy
implementation. See https://angular.io/docs/ts/latest/guide/pipes.html#!#no-filter-pipe
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments