@@ -11,6 +11,7 @@ import {
1111 Injector ,
1212 ApplicationRef ,
1313} from '@angular/core' ;
14+ import { CommonModule } from '@angular/common' ;
1415import { TemplatePortalDirective , PortalHostDirective , PortalModule } from './portal-directives' ;
1516import { Portal , ComponentPortal } from './portal' ;
1617import { DomPortalHost } from './dom-portal-host' ;
@@ -258,6 +259,15 @@ describe('Portals', () => {
258259 expect ( someDomElement . textContent ) . toContain ( 'Cake' ) ;
259260 } ) ;
260261
262+ it ( 'should render a template portal with an inner template' , ( ) => {
263+ let fixture = TestBed . createComponent ( PortalTestApp ) ;
264+ fixture . detectChanges ( ) ;
265+
266+ fixture . componentInstance . portalWithTemplate . attach ( host ) ;
267+
268+ expect ( someDomElement . textContent ) . toContain ( 'Durian' ) ;
269+ } ) ;
270+
261271 it ( 'should attach and detach a template portal with a binding' , ( ) => {
262272 let fixture = TestBed . createComponent ( PortalTestApp ) ;
263273
@@ -384,14 +394,21 @@ class ArbitraryViewContainerRefComponent {
384394 <ng-template cdk-portal>Cake</ng-template>
385395
386396 <div *cdk-portal>Pie</div>
387-
388- <ng-template cdk-portal> {{fruit}} </ng-template>` ,
397+ <ng-template cdk-portal> {{fruit}} </ng-template>
398+
399+ <ng-template cdk-portal>
400+ <ul>
401+ <li *ngFor="let fruitName of fruits"> {{fruitName}} </li>
402+ </ul>
403+ </ng-template>
404+ ` ,
389405} )
390406class PortalTestApp {
391407 @ViewChildren ( TemplatePortalDirective ) portals : QueryList < TemplatePortalDirective > ;
392408 @ViewChild ( PortalHostDirective ) portalHost : PortalHostDirective ;
393409 selectedPortal : Portal < any > ;
394410 fruit : string = 'Banana' ;
411+ fruits = [ 'Apple' , 'Pineapple' , 'Durian' ] ;
395412
396413 constructor ( public injector : Injector ) { }
397414
@@ -406,13 +423,17 @@ class PortalTestApp {
406423 get portalWithBinding ( ) {
407424 return this . portals . toArray ( ) [ 2 ] ;
408425 }
426+
427+ get portalWithTemplate ( ) {
428+ return this . portals . toArray ( ) [ 3 ] ;
429+ }
409430}
410431
411432// Create a real (non-test) NgModule as a workaround for
412433// https://github.com/angular/angular/issues/10760
413434const TEST_COMPONENTS = [ PortalTestApp , ArbitraryViewContainerRefComponent , PizzaMsg ] ;
414435@NgModule ( {
415- imports : [ PortalModule ] ,
436+ imports : [ CommonModule , PortalModule ] ,
416437 exports : TEST_COMPONENTS ,
417438 declarations : TEST_COMPONENTS ,
418439 entryComponents : TEST_COMPONENTS ,
0 commit comments