@@ -15,7 +15,7 @@ import {
1515
1616import { ListWrapper } from 'angular2/src/core/facade/collection' ;
1717
18- import { Component , View } from 'angular2/angular2' ;
18+ import { Component , View , TemplateRef , ContentChild } from 'angular2/angular2' ;
1919
2020import { NgFor } from 'angular2/src/core/directives/ng_for' ;
2121
@@ -309,6 +309,25 @@ export function main() {
309309 } ) ;
310310 } ) ) ;
311311
312+ it ( 'should allow to use a custom template' ,
313+ inject ( [ TestComponentBuilder , AsyncTestCompleter ] , ( tcb : TestComponentBuilder , async ) => {
314+ tcb . overrideTemplate (
315+ TestComponent ,
316+ '<ul><template ng-for [ng-for-of]="items" [ng-for-template]="contentTpl"></template></ul>' )
317+ . overrideTemplate (
318+ ComponentUsingTestComponent ,
319+ '<test-cmp><li template="#item #i=index">{{i}}: {{item}};</li></test-cmp>' )
320+ . createAsync ( ComponentUsingTestComponent )
321+ . then ( ( rootTC ) => {
322+ var testComponent = rootTC . debugElement . componentViewChildren [ 0 ] ;
323+ testComponent . componentInstance . items = [ 'a' , 'b' , 'c' ] ;
324+ rootTC . detectChanges ( ) ;
325+ expect ( testComponent . nativeElement ) . toHaveText ( '0: a;1: b;2: c;' ) ;
326+
327+ async . done ( ) ;
328+ } ) ;
329+ } ) ) ;
330+
312331 } ) ;
313332}
314333
@@ -319,6 +338,14 @@ class Foo {
319338@Component ( { selector : 'test-cmp' } )
320339@View ( { directives : [ NgFor ] } )
321340class TestComponent {
341+ @ContentChild ( TemplateRef ) contentTpl : TemplateRef ;
342+ items : any ;
343+ constructor ( ) { this . items = [ 1 , 2 ] ; }
344+ }
345+
346+ @Component ( { selector : 'outer-cmp' } )
347+ @View ( { directives : [ TestComponent ] } )
348+ class ComponentUsingTestComponent {
322349 items : any ;
323350 constructor ( ) { this . items = [ 1 , 2 ] ; }
324351}
0 commit comments