Search code examples
angularjsng-bind-html

Using ng-class with value from $scope


I have the following code:

<td ng-class="severityColor" ng-model="severity">text</td>

Css looks like:

.critical {
  color: red;
}
.warning {
  color: orange;
}
.info {
  color: black;
}

Severity is a variable inside $scope, and if I do something like:

<p>{{severity}}</p>

It prints either critical, warning or info accordingly. But this isn't changing the text color on the td tag. Am i missing something here?


Solution

  • I'm completely retarded... Just as soon as I posted the question the answer became obvious... just changed the code to be:

    <td ng-class="severity">text</td>