AngularJS Tutorial - ng-repeat loops array from scope








The following code shows how to use ng-repeat to loop array from scope.

Example


<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
</head><!-- www  .ja  v  a2s  .c om-->
<body ng:controller="Main" ng:app>
  <body ng-app>
  <div ng-repeat="entity in entities">
    Hello {{entity.id}}!
  </div>
</body>
<script type='text/javascript'>
function Main($scope) {
    $scope.entities = [{id:'angularjs'},{id:'javascript'}];
};
</script>
</body>
</html>

The code above is rendered as follows: