angular.widget.@ng:repeat

Work in Progress This page is currently being revised. It might be incomplete or contain inaccuracies.

Description

ng:repeat instantiates a template once per item from a collection. The collection is enumerated with ng:repeat-index attribute starting from 0. Each template instance gets its own scope where the given loop variable is set to the current collection item and $index is set to the item index or key.

There are special properties exposed on the local scope of each template instance:

NOTE: ng:repeat looks like a directive, but is actually an attribute widget.

Dependencies

Usage

In HTML Template Binding

<ANY ng:repeat="repeat_expression">
   ...
</ANY>

Parameters

Example

This example initializes the scope to a list of names and than uses ng:repeat to display every person.

<div ng:init="friends = [{name:'John', age:25}, {name:'Mary', age:28}]"> I have {{friends.length}} friends. They are: <ul> <li ng:repeat="friend in friends"> [{{$index + 1}}] {{friend.name}} who is {{friend.age}} years old. </li> </ul> </div>