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:
$index
– {number}
– iterator offset of the repeated element (0..length-1)$position
– {string} – position of the repeated element in the iterator. One of: 'first'
,
'middle'
or 'last'
.NOTE: ng:repeat
looks like a directive, but is actually an attribute widget.
<ANY @ng:repeat="repeat_expression"> ... </ANY>
variable in expression
– where variable is the user defined loop variable and expression
is a scope expression giving the collection to enumerate.
For example: track in cd.tracks
.
(key, value) in expression
– where key
and value
can be any user defined identifiers,
and expression
is the scope expression giving the collection to enumerate.
For example: (name, age) in {'adam':10, 'amalie':12}
.
This example initializes the scope to a list of names and
than uses ng:repeat
to display every person.