@@ -17,6 +17,8 @@ import {
17
17
EventEmitter ,
18
18
Inject ,
19
19
Optional ,
20
+ ChangeDetectionStrategy ,
21
+ ChangeDetectorRef ,
20
22
} from '@angular/core' ;
21
23
import {
22
24
animate ,
@@ -50,6 +52,7 @@ export function throwMdDialogContentAlreadyAttachedError() {
50
52
selector : 'md-dialog-container, mat-dialog-container' ,
51
53
templateUrl : 'dialog-container.html' ,
52
54
styleUrls : [ 'dialog.css' ] ,
55
+ changeDetection : ChangeDetectionStrategy . OnPush ,
53
56
encapsulation : ViewEncapsulation . None ,
54
57
animations : [
55
58
trigger ( 'slideDialog' , [
@@ -100,6 +103,7 @@ export class MdDialogContainer extends BasePortalHost {
100
103
private _ngZone : NgZone ,
101
104
private _elementRef : ElementRef ,
102
105
private _focusTrapFactory : FocusTrapFactory ,
106
+ private _changeDetectorRef : ChangeDetectorRef ,
103
107
@Optional ( ) @Inject ( DOCUMENT ) _document : any ) {
104
108
105
109
super ( ) ;
@@ -116,7 +120,12 @@ export class MdDialogContainer extends BasePortalHost {
116
120
}
117
121
118
122
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 ;
120
129
}
121
130
122
131
/**
@@ -129,7 +138,12 @@ export class MdDialogContainer extends BasePortalHost {
129
138
}
130
139
131
140
this . _savePreviouslyFocusedElement ( ) ;
132
- return this . _portalHost . attachTemplatePortal ( portal ) ;
141
+ const locals = this . _portalHost . attachTemplatePortal ( portal ) ;
142
+
143
+ // Ensure that the initial view change are picked up.
144
+ this . _changeDetectorRef . markForCheck ( ) ;
145
+
146
+ return locals ;
133
147
}
134
148
135
149
/** Moves the focus inside the focus trap. */
0 commit comments