Skip to content

feat(Dialog): Public API for dialog component ComponentRef #27534

Closed

Description

@Klaster1

Feature Description

Expose the ComponentRef of the component dialog is shown as a property of MatDialogRef:

const {componentRef} = dialogRef

Use Case

I have a custom helper that allows for seamless routing to dialogs, as if these were regular routes. Angular 16 added "Passing router data as component inputs" that I really liked enough to update the dialog helper, achieving the same result. Unfortunately, the only way to grab a ComponentRef off MatDialogRef is with private API:

const componentRef = dialogRef._containerInstance._portalOutlet.attachedRef;
const mirror = reflectComponentType(dialogComponent);
if (componentRef instanceof ComponentRef && mirror) {
  for (const { templateName } of mirror.inputs) {
    componentRef.setInput(templateName, injector.get(ActivatedRouteSnapshot).data[templateName]);
  }
}

Activity

  1. added
    feature
    needs triage
    on Jul 28, 2023
  2. self-assigned this
    on Jul 28, 2023
  3. added
    P4
    and removed
    needs triage
    on Jul 28, 2023
  4. added a commit that references this issue on Jul 29, 2023
    caa6645
  5. added a commit that references this issue on Jul 31, 2023
    30c3e13
  6. added a commit that references this issue on Aug 2, 2023
    ff09807
  7. angular-automatic-lock-bot commented on Aug 31, 2023

    @angular-automatic-lock-bot

    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.

  8. locked and limited conversation to collaborators on Aug 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P4area: cdk/dialogfeature

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions