AngularJS Tutorial - ng-class-odd for odd








We can add style for odd numbered item with ng-class-odd.

Example


<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
<style>
.odd {<!--from www  .j a  v a 2s .c  o m-->
   color: red;
}
.even {
   color: blue;
}
</style>
</head>
<body>
  <div ng-app="">
  <ol ng-init="names=['John', 'Mary', 'Cate', 'Suz']">
    <li ng-repeat="name in names"  ng-class-odd="'odd'" ng-class-even="'even'">
       {{name}}
    </li>
  </ol>
</div>
</body>
</html>

The code above is rendered as follows: