I am trying to apply a specific class to an li element if 2 conditions are true, so I wrote the following code but it is not seem to be working
ng-class="{current:isActive('/'), loginStatus: false}"
Can someone please tell me what I am doing wrong and how to fix it so that the class is applied only if route is at / and loginstatus is false? Thanks
The key should define the class you want, and the rest should be the expression to evaluate, which determines if the class is shown...
ng-class="{current:isActive('/') && loginStatus === false}"
What you were saying was more like... set class current
if isActive('/')
and also set class loginStatus
if false
is true.
Right now it is set up to add the class current
if isActive('/')
return true, and the class loginStatus
if false
is true
(which it, obviously, never will be).
What you need to do, to add the class current
if isActive('/')
AND loginStatus == false
, is simply
ng-class="{current:isActive('/') && !loginStatus}"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With