@@ -17,6 +17,8 @@ import {
1717 EventEmitter ,
1818 Inject ,
1919 Optional ,
20+ ChangeDetectionStrategy ,
21+ ChangeDetectorRef ,
2022} from '@angular/core' ;
2123import {
2224 animate ,
@@ -50,6 +52,7 @@ export function throwMdDialogContentAlreadyAttachedError() {
5052 selector : 'md-dialog-container, mat-dialog-container' ,
5153 templateUrl : 'dialog-container.html' ,
5254 styleUrls : [ 'dialog.css' ] ,
55+ changeDetection : ChangeDetectionStrategy . OnPush ,
5356 encapsulation : ViewEncapsulation . None ,
5457 animations : [
5558 trigger ( 'slideDialog' , [
@@ -100,6 +103,7 @@ export class MdDialogContainer extends BasePortalHost {
100103 private _ngZone : NgZone ,
101104 private _elementRef : ElementRef ,
102105 private _focusTrapFactory : FocusTrapFactory ,
106+ private _changeDetectorRef : ChangeDetectorRef ,
103107 @Optional ( ) @Inject ( DOCUMENT ) _document : any ) {
104108
105109 super ( ) ;
@@ -116,7 +120,12 @@ export class MdDialogContainer extends BasePortalHost {
116120 }
117121
118122 this . _savePreviouslyFocusedElement ( ) ;
119- return this . _portalHost . attachComponentPortal ( portal ) ;
123+ const componentRef = this . _portalHost . attachComponentPortal ( portal ) ;
124+
125+ // Ensure that the initial view change are picked up.
126+ componentRef . changeDetectorRef . markForCheck ( ) ;
127+
128+ return componentRef ;
120129 }
121130
122131 /**
@@ -129,7 +138,13 @@ export class MdDialogContainer extends BasePortalHost {
129138 }
130139
131140 this . _savePreviouslyFocusedElement ( ) ;
132- return this . _portalHost . attachTemplatePortal ( portal ) ;
141+
142+ const locals = this . _portalHost . attachTemplatePortal ( portal ) ;
143+
144+ // Ensure that the initial view change are picked up.
145+ this . _changeDetectorRef . markForCheck ( ) ;
146+
147+ return locals ;
133148 }
134149
135150 /** Moves the focus inside the focus trap. */
0 commit comments