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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -