Wednesday, February 11, 2015

ng-repeat directive

The ng-repeat directive can be used to iterate through a collection and process one item at a time from the collection. This is similar to the foreach loop in C#. The ng-repeat directive comes in handy when we want to display a list of items in an array/collection in the view.

The following example shows how to use the ng-repeat directive to display a list of array items using the ng-repeat directive.

<html ng-app>
<head>
    <meta charset="utf-8" />
    <title>AngularJS - Basic</title>
    <script src="angular.min.js"></script>
</head>
<body>
<div ng-init="Numbers=[1,2,3,4,5]">
<ul>
   <li ng-repeat="n in Numbers">
     {{ n }}
   </li>
  </ul>
</div>
</body>
</html>

Output:


Search Flipkart Products:
Flipkart.com

No comments: