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
Post a Comment