@@ -16,6 +16,8 @@ import {
16
16
EventEmitter ,
17
17
Inject ,
18
18
Optional ,
19
+ ChangeDetectionStrategy ,
20
+ ChangeDetectorRef ,
19
21
} from '@angular/core' ;
20
22
import {
21
23
animate ,
@@ -49,6 +51,7 @@ export function throwMdDialogContentAlreadyAttachedError() {
49
51
selector : 'md-dialog-container, mat-dialog-container' ,
50
52
templateUrl : 'dialog-container.html' ,
51
53
styleUrls : [ 'dialog.css' ] ,
54
+ changeDetection : ChangeDetectionStrategy . OnPush ,
52
55
encapsulation : ViewEncapsulation . None ,
53
56
animations : [
54
57
trigger ( 'slideDialog' , [
@@ -104,6 +107,7 @@ export class MdDialogContainer extends BasePortalHost {
104
107
private _ngZone : NgZone ,
105
108
private _elementRef : ElementRef ,
106
109
private _focusTrapFactory : FocusTrapFactory ,
110
+ private _changeDetectorRef : ChangeDetectorRef ,
107
111
@Optional ( ) @Inject ( DOCUMENT ) _document : any ) {
108
112
109
113
super ( ) ;
@@ -120,7 +124,12 @@ export class MdDialogContainer extends BasePortalHost {
120
124
}
121
125
122
126
this . _savePreviouslyFocusedElement ( ) ;
123
- return this . _portalHost . attachComponentPortal ( portal ) ;
127
+ const componentRef = this . _portalHost . attachComponentPortal ( portal ) ;
128
+
129
+ // Ensure that the initial view change are picked up.
130
+ componentRef . changeDetectorRef . markForCheck ( ) ;
131
+
132
+ return componentRef ;
124
133
}
125
134
126
135
/**
@@ -133,7 +142,12 @@ export class MdDialogContainer extends BasePortalHost {
133
142
}
134
143
135
144
this . _savePreviouslyFocusedElement ( ) ;
136
- return this . _portalHost . attachTemplatePortal ( portal ) ;
145
+ const locals = this . _portalHost . attachTemplatePortal ( portal ) ;
146
+
147
+ // Ensure that the initial view change are picked up.
148
+ this . _changeDetectorRef . markForCheck ( ) ;
149
+
150
+ return locals ;
137
151
}
138
152
139
153
/** Moves the focus inside the focus trap. */
0 commit comments