@@ -16,6 +16,7 @@ import {
1616import { ListWrapper } from 'angular2/src/facade/collection' ;
1717import { Component , View , TemplateRef , ContentChild } from 'angular2/core' ;
1818import { NgFor } from 'angular2/src/common/directives/ng_for' ;
19+ import { NgIf } from 'angular2/src/common/directives/ng_if' ;
1920import { By } from 'angular2/platform/common_dom' ;
2021
2122export function main ( ) {
@@ -232,6 +233,33 @@ export function main() {
232233 } ) ;
233234 } ) ) ;
234235
236+ it ( 'should repeat over nested ngIf that are the last node in the ngFor temlate' ,
237+ inject ( [ TestComponentBuilder , AsyncTestCompleter ] , ( tcb : TestComponentBuilder , async ) => {
238+ var template =
239+ `<div><template ngFor #item [ngForOf]="items" #i="index"><div>{{i}}|</div>` +
240+ `<div *ngIf="i % 2 == 0">even|</div></template></div>` ;
241+
242+ tcb . overrideTemplate ( TestComponent , template )
243+ . createAsync ( TestComponent )
244+ . then ( ( fixture ) => {
245+ var el = fixture . debugElement . nativeElement ;
246+ var items = [ 1 ] ;
247+ fixture . debugElement . componentInstance . items = items ;
248+ fixture . detectChanges ( ) ;
249+ expect ( el ) . toHaveText ( '0|even|' ) ;
250+
251+ items . push ( 1 ) ;
252+ fixture . detectChanges ( ) ;
253+ expect ( el ) . toHaveText ( '0|even|1|' ) ;
254+
255+ items . push ( 1 ) ;
256+ fixture . detectChanges ( ) ;
257+ expect ( el ) . toHaveText ( '0|even|1|2|even|' ) ;
258+
259+ async . done ( ) ;
260+ } ) ;
261+ } ) ) ;
262+
235263 it ( 'should display indices correctly' ,
236264 inject ( [ TestComponentBuilder , AsyncTestCompleter ] , ( tcb : TestComponentBuilder , async ) => {
237265 var template =
@@ -445,7 +473,7 @@ class Foo {
445473}
446474
447475@Component ( { selector : 'test-cmp' } )
448- @View ( { directives : [ NgFor ] } )
476+ @View ( { directives : [ NgFor , NgIf ] } )
449477class TestComponent {
450478 @ContentChild ( TemplateRef ) contentTpl : TemplateRef ;
451479 items : any ;
0 commit comments