ng-repeat loops array from scope

Description

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><!--from  w w w .  ja  va  2s . com-->
<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>

Click to view the demo





















Home »
  AngularJS »
    AngularJS Example »




Controller
Directives
Expression
Filter
Form
Inject
Scope
Server
Style
Template
Utilities