latest Post

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

    <table class="table table-bordered">
        <tr ng-repeat="empin empDetails">
            <td>{{emp.name}}</td>
            <td>{{emp.salary}}</td>
        </tr>
    </table>

Here, ng-repeat directive iterates over the empDetails collection and creates a <tr> 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

    $index
    $first
    $middle
    $last

About Mallikarjun A

Mallikarjun A
Recommended Posts × +

0 comments:

Post a Comment