@@ -368,6 +368,12 @@ describe('Portals', () => {
368
368
369
369
expect ( spy ) . toHaveBeenCalled ( ) ;
370
370
} ) ;
371
+
372
+ it ( 'should run change detection in the created component when a ComponentPortal is attached' ,
373
+ ( ) => {
374
+ host . attach ( new ComponentPortal ( ComponentWithBoundVariable , someViewContainerRef ) ) ;
375
+ expect ( someDomElement . textContent ) . toContain ( 'initial value' ) ;
376
+ } ) ;
371
377
} ) ;
372
378
} ) ;
373
379
@@ -404,6 +410,15 @@ class ArbitraryViewContainerRefComponent {
404
410
constructor ( public viewContainerRef : ViewContainerRef , public injector : Injector ) { }
405
411
}
406
412
413
+ /** Simple component with a bound variable in the template */
414
+ @Component ( {
415
+ selector : 'bound-text' ,
416
+ template : '<p>{{text}}</p>'
417
+ } )
418
+ class ComponentWithBoundVariable {
419
+ text : string = 'initial value' ;
420
+ }
421
+
407
422
408
423
/** Test-bed component that contains a portal host and a couple of template portals. */
409
424
@Component ( {
@@ -453,7 +468,12 @@ class PortalTestApp {
453
468
454
469
// Create a real (non-test) NgModule as a workaround for
455
470
// https://github.com/angular/angular/issues/10760
456
- const TEST_COMPONENTS = [ PortalTestApp , ArbitraryViewContainerRefComponent , PizzaMsg ] ;
471
+ const TEST_COMPONENTS = [
472
+ PortalTestApp ,
473
+ ArbitraryViewContainerRefComponent ,
474
+ PizzaMsg ,
475
+ ComponentWithBoundVariable
476
+ ] ;
457
477
@NgModule ( {
458
478
imports : [ CommonModule , PortalModule ] ,
459
479
exports : TEST_COMPONENTS ,
0 commit comments