Tutorial 19 – how to use ng-class in angularjs

How to use ng-class in angularjs?

This sample will help you know about using ng-class in AngularJS. You will like this directive after you run ng-class example as below.

 <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) {  
            }]);  
     </script>  
 <style>  
     .red {  
       padding: 20px;  
       background-color: red;  
       color: #FFF;  
     }  
     .border {  
       border: solid 1px blue;  
     }  
   </style>  
   </head>  
   <body ng-app="MyForm">  
 <h3>please input a numbe.r</h3>  
 <p ng-class="[border, red]">Learn angularjs free at http://angularjsaz.blogspot.com/</p> <br />   
 </body>  
  </html>  

Related post to ng-class tutorial



No comments:

Post a Comment

Popular Posts