AngularJS ng-class-even and ng-class-odd example

AngularJS directives ng-class-even and ng-class-odd work like ng-class except that when these are used with ng-repeat, these apply to even and odd rows.

<style>
.even {color: red;}
.odd {color: blue;}
</style>

<div ng-app="myApp" ng-controller='MyCtrl'>
  <ol ng-init="arr=['One', 'Two', 'Three', 'Four']">
  <li ng-repeat="val in arr" ng-class-even="'even'" ng-class-odd="'odd'">
    {{val}}
  </li>
  </ol>
</div>

<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.min.js"></script>
<script>
  var module = angular.module('myApp', []);
  module.controller('MyCtrl', function($scope) {});
</script>
refresh
Share this article: share on Google+ share on facebook share on linkedin tweet this submit to reddit

Comments

Click here to write/view comments