Tutorial 13 – how to use ng-repeat in AngularJS

How to use ng-repeat in AngularJS?

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

ng-repeat example code 
 <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) {  
 $scope.items = ["Hi", 'Hello', "Welcome"];  
                 $scope.items2 = {  
             name: "Paul",  
             website: "MrPaul.com"  
           };  
             }]);  
     </script>  
   </head>  
   <body ng-app="MyForm">  
 <div ng-repeat="item in items" style="border:solid 1px red; margin: 10px">  
          {{item}}  
     </div>   
      @* AND using (key, value) in expression via ng-repeat *@  
         <div ng-repeat="(key,value) in items2">  
             {{key}} - {{value}}  
      </div>  
   </body>  
  </html>  


No comments:

Post a Comment

Popular Posts