Skip to content

Commit

Permalink
Revert "refactor(material/dialog): use embedded injector to provide r…
Browse files Browse the repository at this point in the history
…ef to template dialogs"

This reverts commit 6d0487b.
  • Loading branch information
crisbeto committed Mar 16, 2022
1 parent 33d07df commit 34aa846
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
4 changes: 0 additions & 4 deletions src/material/dialog/dialog-content-directives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
15 changes: 5 additions & 10 deletions src/material/dialog/dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,21 +292,16 @@ export abstract class _MatDialogBase<C extends _MatDialogContainerBase> 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<T>(config, dialogRef, dialogContainer);

if (componentOrTemplateRef instanceof TemplateRef) {
dialogContainer.attachTemplatePortal(
new TemplatePortal<T>(
componentOrTemplateRef,
null!,
<any>{
$implicit: config.data,
dialogRef,
},
injector,
),
new TemplatePortal<T>(componentOrTemplateRef, null!, <any>{
$implicit: config.data,
dialogRef,
}),
);
} else {
const injector = this._createInjector<T>(config, dialogRef, dialogContainer);
const contentRef = dialogContainer.attachComponentPortal<T>(
new ComponentPortal(
componentOrTemplateRef,
Expand Down

0 comments on commit 34aa846

Please sign in to comment.