- The ng-repeat directive is used to clones a HTML element loop for each item in a collection.
- The collection should be an object or array.
- The ng-repeat directive especially suitable for ordered list, unordered-list or HTML table.
Syntax for ng-repeat Directive in AngularJS:
Parameter Values:
Value |
Description |
(key, value) in myObj |
Angular relies on the order returned by the browser when running for key in myObj |
Sample code for ng-repeat Directive in AngularJS:
Data:
- Collection of data has been defined using array for our AngularJS Application.
HTML:
- Viewable HTML contents in AngularJS Application.
Logic:
- Controller logic for the AngularJS application.
Code Explanation for ng-repeat Directive in AngularJS:
- The ng-app specifies the root element (<div>) to define AngularJS application.
- The ng-controller is a directive to control the AngularJS Application.
- The ng-repeat is used to repeat the <li> tag for each data in the list.
- The angular.module used to create an Application module.
- The app.controller controls the Application module.
- The $scope.list is a collection of data stored as array in the $scope object.
Sample Output for ng-repeat Directive in AngularJS:
- The output displays list of tutorials by using ng-repeat Directive.
Related Searches to angularjs ng-repeat directive
ng-repeat table
ng-repeat array
ng-repeat object
ng-repeat not working
ng-repeat for loop
ng-repeat $index
ng-repeat key value
ng-repeat array of objects
ng repeat track by index
nested ng-repeat index
ng-repeat filter
ng-repeat orderby
ng-repeat-start
angularjs tutorials