@@ -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' , [
@@ -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