Sunday, 1 September 2013

How can I switch between using one class or another in AngularJS?

How can I switch between using one class or another in AngularJS?

I have the following code:
<i style="margin-right: 0.5em; color: #EEEEEE;" class="icon-home
icon-4x"></i>
I would like to change the color of the SVG icon depending on if my
ui-router state as follows:
If the state includes 'admin' I would like it to use the class red-icon
If the state does not include 'admin' I would like it to use the class
blue-icon
I have done something like this before:
data-ng-class="{ current: $state.includes('admin') }"
But how can I make it switch between the two colors?

No comments:

Post a Comment