AngularJS ng-class-oddDirective
AngularJS Example
Set class="striped" for the odd rows of the table:
<table ng-controller="myCtrl">
<tr ng-repeat="x in records" ng-class-odd="'striped'">
<td>{{x.Name}}</td>
<td>{{x.Country}}</td>
</tr>
</table>
<tr ng-repeat="x in records" ng-class-odd="'striped'">
<td>{{x.Name}}</td>
<td>{{x.Country}}</td>
</tr>
</table>
Try it Yourself »
Definition and Usage
ng-class-oddThe directive is used to dynamically bind one or more CSS classes to HTML elements, but only applies to odd rows.
ng-class-oddThe directive needs to be used in conjunction withng-repeatthe directive.
ng-class-oddThe directive is recommended for styling table rendering, but all HTML elements are supported.
Syntax
<element ng-class-odd="expression"></element>
Supported by all HTML elements.
Parameter Values
| Value | Description |
|---|---|
| expression | Expression specifying one or more CSS classes. |
Other Extensions
AngularJS Reference Manual