AngularJS ng-repeat

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Introduction

The ngRepeat directive instantiates a template once per item from a collection. The collection must be an array or an object. 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.

Syntax

  • <element ng-repeat="expression"></element>
  • <div ng-repeat="(key, value) in myObj">...</div>
  • <div ng-repeat="variable in expression">...</div>

Parameters

VariableDetails
$indexnumber iterator offset of the repeated element (0..length-1)
$firstboolean true if the repeated element is first in the iterator.
$middleboolean true if the repeated element is between the first and last in the iterator.
$lastboolean true if the repeated element is last in the iterator.
$evenboolean true if the iterator position $index is even (otherwise false).
$oddboolean true if the iterator position $index is odd (otherwise false).

Remarks

AngularJS provides these parameters as special variables that are available in the ng-repeat expression and anywhere inside of the HTML tag on which the ng-repeat lives.



Got any AngularJS Question?