Explain ng-repeat directive.
The ng-repeat directive is the most used and very useful AngularJS Directive feature. It iterates over a collection of items and creates DOM elements. It constantly monitors the source of data to re-render a template in response to change.
Syntax of ng-repeat
1.
2.
3.
4.
5.
6.
{{emp.name}} {{emp.salary}}
Here, ng-repeat directive iterates over the empDetails collection and creates a
DOM element for each entry in the collection.
The ng-repeat directive creates a new scope for each element of a collection.
Variables created by ng-repeat
AngularJS ng-repeat directive creates so many special variables in a scope created for each and every individual entry. These variables are very important to find the position of an element within a collection.
Below are the some important variables created by ng-repeat
1. $index
2. $first
3. $middle
4. $last
Comments
Post a Comment