2

How to use nested if in style css Lightning Design System. this is working fine

<div class="{!v.case.Priority == 'Closed' 
                     ? 'row closed' : 'row '}" >

But when I write the same for nested if condition it doesn't work

<div class="{!v.case.Priority == 'Closed' 
                 ? 'row closed' : v.case.Priority == 'New' 
                 ? 'row new' : 'row '}" >
2
  • If you don't find a solution to your code, you could try adding a wrapper and instead of doing v.case.Priority do v.caseWrapper.parsedPriority.
    – D. Cruz
    Commented Aug 2, 2016 at 23:10
  • 1
    Do parentheses help i.e. v.case.Priority == 'Closed' ? 'row closed' : (v.case.Priority == 'New' ? 'row new' : 'row ')?
    – Keith C
    Commented Aug 2, 2016 at 23:27

1 Answer 1

1

If you can't nest the terniary operator, then concatenate two (or more) of them. Try something like this:

"{! v.case.Priority == 'Closed' ? 'row closed' : '' + 
   v.case.Priority == 'New' ? 'row new' : 'row ' }"

One other option (which I haven't tried) would be to use the function version of the terniary operator - if(condition, true, false) and see if that is able to be nested.

Reference here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .