Catfish
Catfish

Reputation: 19294

AngularJS - ng-class with value from ng-repeat

I'm trying to set the class of a tr using ng-class with the value of ng-repeat. All the examples I see online seem to call a function. Can i just set the ng-class with a value rather than using a function?

None of these work.

<tr ng-class="{{res.resopnse.label}}" ng-repeat="res in responses">
<tr ng-class="res.resopnse.label" ng-repeat="res in responses">
<tr ng-class="{res.resopnse.label}" ng-repeat="res in responses">

Upvotes: 1

Views: 316

Answers (1)

Davin Tryon
Davin Tryon

Reputation: 67296

If you have no conditional logic, you can just interpolate into class attribute directly:

<tr class="{{res.resopnse.label}}" ng-repeat="res in responses">

Upvotes: 1

Related Questions