zomdar
zomdar

Reputation: 273

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?

Upvotes: 1

Views: 96

Answers (1)

Pranay Rana
Pranay Rana

Reputation: 176896

can you try like this , make use of ternary operator

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

Upvotes: 2

Related Questions