diff --git a/src/material/dialog/dialog-content-directives.ts b/src/material/dialog/dialog-content-directives.ts index 6d614f956c5d..5c782353e57a 100644 --- a/src/material/dialog/dialog-content-directives.ts +++ b/src/material/dialog/dialog-content-directives.ts @@ -149,10 +149,6 @@ export class MatDialogContent {} }) export class MatDialogActions {} -// TODO(crisbeto): this utility shouldn't be necessary anymore, because the dialog ref is provided -// both to component and template dialogs through DI. We need to keep it around, because there are -// some internal wrappers around `MatDialog` that happened to work by accident, because we had this -// fallback logic in place. /** * Finds the closest MatDialogRef to an element by looking at the DOM. * @param element Element relative to which to look for a dialog. diff --git a/src/material/dialog/dialog.ts b/src/material/dialog/dialog.ts index 45abc09b56a8..4aee4b08aa60 100644 --- a/src/material/dialog/dialog.ts +++ b/src/material/dialog/dialog.ts @@ -292,21 +292,16 @@ export abstract class _MatDialogBase implemen // Create a reference to the dialog we're creating in order to give the user a handle // to modify and close it. const dialogRef = new this._dialogRefConstructor(overlayRef, dialogContainer, config.id); - const injector = this._createInjector(config, dialogRef, dialogContainer); if (componentOrTemplateRef instanceof TemplateRef) { dialogContainer.attachTemplatePortal( - new TemplatePortal( - componentOrTemplateRef, - null!, - { - $implicit: config.data, - dialogRef, - }, - injector, - ), + new TemplatePortal(componentOrTemplateRef, null!, { + $implicit: config.data, + dialogRef, + }), ); } else { + const injector = this._createInjector(config, dialogRef, dialogContainer); const contentRef = dialogContainer.attachComponentPortal( new ComponentPortal( componentOrTemplateRef,