Skip to content

feat(material/dialog): add support for explicit injector #24580

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 25, 2022
Merged

feat(material/dialog): add support for explicit injector #24580

merged 1 commit into from
Mar 25, 2022

Conversation

arturovt
Copy link
Contributor

@arturovt arturovt commented Mar 11, 2022

Dialog components can be loaded asynchronously through the dynamic import, and they might be declared in the module that lives in the same file. The component might depend on the providers declared in this module. Currently, the MatDialog does not allow providing a custom injector. It only allows to pass the viewContainerRef and takes its injector if provided.

The real use case from our app:

export class SomeComponent {
  constructor(private dialog: MatDialog, private injector: Injector) {}

  openDialog(): void {
    import('./dialog').then((m) => {
      const ngModuleRef = createNgModuleRef(
        m.DialogModule,
        this.injector
      );
      this.dialog.open(m.DialogComponent, {
        injector: ngModuleRef.injector,
      });
    });
  }
}

Copy link
Member

@devversion devversion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. This needs some more discussion, but overall the use-case seems reasonable to me.

Copy link
Member

@devversion devversion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM overall, just a few minor comments. Still wanting feedback from others though.

@arturovt arturovt changed the title feat(material/dialog): add support for standalone injector feat(material/dialog): add support for explicit injector Mar 16, 2022
@devversion devversion added target: minor This PR is targeted for the next minor release area: material/dialog labels Mar 16, 2022
@andrewseguin andrewseguin added the action: merge The PR is ready for merge by the caretaker label Mar 24, 2022
@andrewseguin andrewseguin merged commit 5a8ebb1 into angular:master Mar 25, 2022
@arturovt arturovt deleted the feat/dialog-injector branch March 25, 2022 15:25
forsti0506 pushed a commit to forsti0506/components that referenced this pull request Apr 3, 2022
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Apr 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: material/dialog target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants