I tried to implement ng-class-even and ng-class-odd ( from angular 1) type behaviour in angular 2 application.
I have written the code below and its working fine, I
update (Angular4)
original (Angular2)
This should work:
{{employee.name}}
NgFor
provides several exported values that can be aliased to local variables:
index
will be set to the current loop iteration for each template context.
first
will be set to a boolean value indicating whether the item is the first one in the iteration. (since beta.15)
last
will be set to a boolean value indicating whether the item is the last one in the iteration.
even
will be set to a boolean value indicating whether this item has an even index.
odd
will be set to a boolean value indicating whether this item has an odd index.
Plunker
See also https://angular.io/docs/ts/latest/api/common/index/NgFor-directive.html