Search code examples
cssangularjsng-class

using ng-class to toggle class


I have a function called isApplication that does a validation on if a certain application is true or false. I want it to display a different bootstrap class depending on the results of the function

I want to use this function to determine which class gets printed on a certain div....for example

html:

<div ng-class="{'col-md-6':isApplication, 'col-md-3':!isApplication}"></div>

it doesnt seem to be working like the way i want it to...am i not using ng-class right?


Solution

  • can you try like this , make use of ternary operator

    ng-class="isApplication ? 'col-md-6' : 'col-md-3'">