Angular2 Use sort pipe only when certain value or boolean is true

CommonSenseCode

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?

Kevin Le

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

display only when boolean is true

From Dev

Checkbox checked if boolean is true with Angular2

From Dev

Given string will only print when boolean is false, not when true

From Dev

Angular2 pipe dynamic value not taking

From Dev

Making actions appears in JQGrid only when a boolean is true

From Dev

Angular2 use basic pipe in custom pipe

From Dev

Passing a true value to a boolean

From Dev

Boolean true value in Hibernate

From Dev

Passing a true value to a boolean

From Dev

Event when boolean is true

From Dev

Getting a false Boolean value when I should be getting true

From Dev

jQuery: Fire function only when certain media query is true

From Dev

Boolean in a constructor only setting to true

From Dev

How to lookup all rows in an SQL database that have a certain Boolean column value of true in asp.net?

From Dev

When using jquery ui sortable, Is there a way to programatically sort by a certain value?

From Dev

Angular 2. Issue with *ngFor, when i use Pipe

From Dev

Why not use only boolean

From Dev

Why not use only boolean

From Dev

MySQL: "= true" vs "is true" on BOOLEAN. When is it advisable to use which one? And Which one is vendor independent?

From Dev

Javascript comparing boolean value to True

From Dev

Angular2 rc.6 Use pipe in component

From Dev

angular2 – use global service through a custom pipe

From Dev

Can I use '==' with pipe ( | ) in angular2 templates?

From Dev

Send an email when a boolean is true

From Dev

Sort by boolean value inside collect

From Dev

boolean value in Angular2 viewmodel does not update *ngIf template

From Dev

Dart Angular2 - bind component boolean with checkbox value

From Dev

angular2 ngfor only if index is less than certain number

From Dev

How to specify event to trigger only certain keystroke in Angular2

Related Related

  1. 1

    display only when boolean is true

  2. 2

    Checkbox checked if boolean is true with Angular2

  3. 3

    Given string will only print when boolean is false, not when true

  4. 4

    Angular2 pipe dynamic value not taking

  5. 5

    Making actions appears in JQGrid only when a boolean is true

  6. 6

    Angular2 use basic pipe in custom pipe

  7. 7

    Passing a true value to a boolean

  8. 8

    Boolean true value in Hibernate

  9. 9

    Passing a true value to a boolean

  10. 10

    Event when boolean is true

  11. 11

    Getting a false Boolean value when I should be getting true

  12. 12

    jQuery: Fire function only when certain media query is true

  13. 13

    Boolean in a constructor only setting to true

  14. 14

    How to lookup all rows in an SQL database that have a certain Boolean column value of true in asp.net?

  15. 15

    When using jquery ui sortable, Is there a way to programatically sort by a certain value?

  16. 16

    Angular 2. Issue with *ngFor, when i use Pipe

  17. 17

    Why not use only boolean

  18. 18

    Why not use only boolean

  19. 19

    MySQL: "= true" vs "is true" on BOOLEAN. When is it advisable to use which one? And Which one is vendor independent?

  20. 20

    Javascript comparing boolean value to True

  21. 21

    Angular2 rc.6 Use pipe in component

  22. 22

    angular2 – use global service through a custom pipe

  23. 23

    Can I use '==' with pipe ( | ) in angular2 templates?

  24. 24

    Send an email when a boolean is true

  25. 25

    Sort by boolean value inside collect

  26. 26

    boolean value in Angular2 viewmodel does not update *ngIf template

  27. 27

    Dart Angular2 - bind component boolean with checkbox value

  28. 28

    angular2 ngfor only if index is less than certain number

  29. 29

    How to specify event to trigger only certain keystroke in Angular2

HotTag

Archive