diff --git a/src/lib/dialog/dialog-container.ts b/src/lib/dialog/dialog-container.ts index 61ae1338cff2..d99b19d52be6 100644 --- a/src/lib/dialog/dialog-container.ts +++ b/src/lib/dialog/dialog-container.ts @@ -17,6 +17,7 @@ import { Inject, Optional, ChangeDetectorRef, + ChangeDetectionStrategy, } from '@angular/core'; import { animate, @@ -51,6 +52,7 @@ export function throwMdDialogContentAlreadyAttachedError() { templateUrl: 'dialog-container.html', styleUrls: ['dialog.css'], encapsulation: ViewEncapsulation.None, + changeDetection: ChangeDetectionStrategy.OnPush, animations: [ trigger('slideDialog', [ // Note: The `enter` animation doesn't transition to something like `translate3d(0, 0, 0) @@ -118,7 +120,13 @@ export class MdDialogContainer extends BasePortalHost { } this._savePreviouslyFocusedElement(); - return this._portalHost.attachComponentPortal(portal); + + const componentRef = this._portalHost.attachComponentPortal(portal); + + // Ensure that the initial view change are picked up. + componentRef.changeDetectorRef.markForCheck(); + + return componentRef; } /** @@ -131,7 +139,12 @@ export class MdDialogContainer extends BasePortalHost { } this._savePreviouslyFocusedElement(); - return this._portalHost.attachTemplatePortal(portal); + + const locals = this._portalHost.attachTemplatePortal(portal); + + this._changeDetectorRef.markForCheck(); + + return locals; } /** Moves the focus inside the focus trap. */