Angularjs Examples

AJS Examples


AngularJS ng-class-even Directive

The AngularJS ng-class-even directive is similar to ng-class directive. It is work in conjunction with ng-repeat and take effect only on even rows.

Syntax

<span ng-class-odd="'odd'" ng-class-even="'even'">
<input type="radio" ng-model="favorite.color" 
ng-value="name" id="{{name}}" name="color"> 
{{name}}<br/>
</span>

AngularJS ng-class-even Directive Example

<!DOCTYPE html>    
<html>    
<head> <!-- www.techstrikers.com -->    
<title>ngClassEven Test Sample</title> 
  <style>
    .odd {
  color: red;
  }
  .even {
    color: black;
  }
  </style>
    
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.min.js"></script>    
    
<script>    
  var app = angular.module('EvenExample', [])
    app.controller('EvenController', ['$scope', function($scope) {
      $scope.names = ['Red', 'Blue', 'Green','Yellow','White','Black'];
      $scope.favorite = { color: 'Green' };
    }]);  
</script>    
</head>    
<body style="background-color:#DDE4E9;" ng-app="EvenExample">    
  <fieldset style="background-color:#DDE4E9;">      
    <legend>AngulerJS ngClassEven Example</legend>      
<div ng-controller="EvenController">
  <form name="myform">
    <label ng-repeat="name in names" for="{{name}}">
      <span ng-class-odd="'odd'" ng-class-even="'even'">
       <input type="radio" ng-model="favorite.color" ng-value="name"
              id="{{name}}" name="color"> {{name}}<br/>
          </span>
     </label>
  </form>
</div>
 </fieldset>     
</body>    
</html>
See Live Example