Repeating HTML Elements in AngularJS

The ng-repeat Directive The ng-repeat directive clones HTML elements once for each item in a collection (in an array).

Sample Code:

<!DOCTYPE html>
<html>
<script src= "http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<body>
<div data-ng-app="" data-ng-init="names=['Test1','Test2','Test3']">
<p>Looping Example in AngularJS</p>
<ul>
<li data-ng-repeat="x in names">
{{ x }}
</li>
</ul>
</div>
</body>
</html>

Output:


Cheers!!!

No comments:

Post a Comment