Reputation: 8487
I've got the following HTML, and I'm trying to print a class using ng-class
to the box, but it doesn't seem to work. What am I doing wrong?
http://plnkr.co/edit/5KqnetMmq5DPe1Dm2ecc?p=preview
<div ng-controller="myObject">
<a href="javascript:void(0)" ng-click="updateClass()">{{ type ? 'One' : 'Two' }}</a>
<div class="box" ng-class="{{ type ? 'one' : 'two' }}"></div>
</div>
Upvotes: 0
Views: 1111
Reputation: 1907
ng-class
as an attribute :
ng-class="expression"
ng-class
as css :
class="ng-class: expression;"
You don't need to write expression in ng-class for more details you should go through ngClass
Upvotes: 0
Reputation: 2402
ng-class gets evaluated on it's own. You don't need the {{}}
<div class="box" ng-class=" type ? 'one' : 'two' "></div>
Upvotes: 4