nofear87
nofear87

Reputation: 869

Use ng-repeat index as class name?

Is it possible to use the $index of ng-repeat in the class name?

Example:

ng-class="{'hand-' + $index: true}"

Thank you!

Upvotes: 10

Views: 4077

Answers (2)

Ashish Gupta
Ashish Gupta

Reputation: 1241

You can use within html class:

class="list-{{$index}}"

for Angular use:

ng-class="['hand-' + $index]"

Upvotes: 1

ryeballar
ryeballar

Reputation: 30088

You can use it like this:

ng-class="['hand-' + $index]"

Additionally, you can use the class attribute to interpolate the class value

class="hand-{{$index}}"

Upvotes: 16

Related Questions