feat(ng_for): Add Even and Odd variables to ng_for

Add even and odd local variables to ng_for to allow developers to style table rows differently and other features.

Closes #4181
This commit is contained in:
Ted Sander
2015-09-14 14:07:59 -07:00
parent db098650ee
commit a15b679494
2 changed files with 40 additions and 0 deletions

View File

@ -90,6 +90,8 @@ export class NgFor implements DoCheck {
private _perViewChange(view, record) {
view.setLocal('\$implicit', record.item);
view.setLocal('index', record.currentIndex);
view.setLocal('even', (record.currentIndex % 2 == 0));
view.setLocal('odd', (record.currentIndex % 2 == 1));
}
static bulkRemove(tuples: RecordViewTuple[], viewContainer: ViewContainerRef): RecordViewTuple[] {