angularjs - Class directive not working when using ng-class with condition -


i tried load directive below not working.

<div ng-class="{'nav-dropdown' : dt.url == null }"> </div> 

it works fine if assigned class this:

<div class="nav-dropdown"> </div> 

edit:

when using method:

<div ng-class="{'nav-dropdown' : dt.url == null }"> </div> 

the class added inside html as

<div class="nav-dropdown"> </div> 

the main problem : directive doesn't show

 <div class="nav-dropdown"><div>this directive template</div></div> 

what want load directive condition: dt.url null. can help?

you can use ternary expression

<ng-class="condition ? 'true' : 'false'"></div> 

so, instead use this:

<div ng-class="{'nav-dropdown' : dt.url == null }"> </div> 

you use this: (this works me)

<div ng-class="dt.url == null ? 'nav-dropdown' : ''"></div> 

Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -