Tutorial 20 – how to use ng-class-odd in angularjs

How to use ng-class-odd in angularjs?

This sample will help you know about using ng-class-odd in AngularJS.



 <html>  
   <head>  
     <title>Angular JS Model</title>  
     <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script>  
     <script>  
       angular.module('MyForm', [])  
           .controller('myController', ['$scope', function($scope) {  
    // List student  
       $scope.students = [  
         { name: "Quang Trung" },  
         { name: "Thanh Thao" },  
         { name: "Hong Chau" },  
         { name: "Quoc Chuong" },  
         { name: "Xuan Hai" },  
         { name: "Van Kinh" },  
         { name: "Van Chinh" },  
         { name: "Van Quyen" },  
         { name: "Van Truong" },  
         { name: "Van Hung" },  
         { name: "Van Hieu" },  
         { name: "Van Nghia" }  
       ];  
            }]);  
     </script>  
  <style>  
     .odd {  
       background: Green;  
       color: #FFF;  
     }  
   </style>  
   </head>  
   <body ng-app="MyForm">  
 <h3>Directive ng-class-odd in AngularJS</h3>  
           <div ng-controller="MyController">  
            <div ng-repeat="student in students" ng-class-odd="'odd'">  
              {{student.name}}  
            </div>  
     </div>  
 </body>  
  </html>  
is this a good directive of angularjs?


No comments:

Post a Comment

Popular Posts