The ngClassOdd
and ngClassEven
directives work exactly as
ngClass, except they work in
conjunction with ngRepeat
and take effect only on odd (even) rows.
This directive can be applied only within the scope of an ngRepeat.
<ANY
ng-class-odd="expression">
...
</ANY>
<ANY class="ng-class-odd: expression;"> ... </ANY>
Param | Type | Details |
---|---|---|
ngClassOdd | expression |
Expression to eval. The result of the evaluation can be a string representing space delimited class names or an array. |
Animation | Occurs |
---|---|
addClass | just before the class is applied to the element |
removeClass | just before the class is removed from the element |
<ol ng-init="names=['John', 'Mary', 'Cate', 'Suz']">
<li ng-repeat="name in names">
<span ng-class-odd="'odd'" ng-class-even="'even'">
{{name}}
</span>
</li>
</ol>
An example on how to implement animations using ngClassOdd
:
<div ng-init="items=['Item 3', 'Item 2', 'Item 1', 'Item 0']">
<button ng-click="items.unshift('Item ' + items.length)">Add item</button>
<hr />
<table>
<tr ng-repeat="item in items" ng-class-odd="'odd'">
<td>{{ item }}</td>
</tr>
</table>
</div>