diff --git a/modules/angular2/src/core/directives/ng_for.ts b/modules/angular2/src/core/directives/ng_for.ts index 62da35517b..74ac217f51 100644 --- a/modules/angular2/src/core/directives/ng_for.ts +++ b/modules/angular2/src/core/directives/ng_for.ts @@ -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[] { diff --git a/modules/angular2/test/core/directives/ng_for_spec.ts b/modules/angular2/test/core/directives/ng_for_spec.ts index 4f9bc1530a..fec85c40cb 100644 --- a/modules/angular2/test/core/directives/ng_for_spec.ts +++ b/modules/angular2/test/core/directives/ng_for_spec.ts @@ -271,6 +271,44 @@ export function main() { }); })); + it('should display even items correctly', + inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { + var template = + '