Iterating with the ng-repeat Directive
Description
First we use directive called ng-init
to define values then
use another directive in AngularJS called ng-repeat
.
Example
<!DOCTYPE html>
<html ng-app>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js">
</script><!-- www . j a v a2s .c o m-->
</head>
<body>
<div data-ng-init="names=['XML','CSS','HTML','Javascript']">
<ul>
<li data-ng-repeat="name in names">{{name}}</li>
</ul>
</div>
</body>
</html>
ng-repeat
loops through all the names,
and then data-bind
or apply the value into the <li>
.