Reputation: 1285
I would like to use a scope variable and and set css dynamically within html.
<div ng-class="myClassScope, { 'dynamic-class': !ifIsNot }">
Upvotes: 0
Views: 3338
Reputation: 370
Is this what you want?
<div ng-class="{ 'dynamic-class': !myClassScope }">
EDIT:
If you want to use multiple ng-class directives, it won't work. See this fiddle
In order to use two ng-class directives, you can nest the elements, or you can bind to the class attribute:
<div ng-class="test_one">
<div ng-class="{ 'test_two': !test_two }">test_two</div>
</div>
<div class="{{test_one}}" ng-class="{ 'test_two': !test_two }">test_three</div>
Upvotes: 2
Reputation: 4552
It your myClassScope is intended to always be applied, use ng-class this way:
<div class="myClassScope" ng-class="{'dynamic-class': !ifIsNot }">
Upvotes: 2