Skip to content

feat(Dialog): Allow passing in component @Inputs when opening a dialog #27776

@cusher

Description

@cusher

Feature Description

To pass data into a dialog, the current suggested pattern is to set data on the DialogConfig parameter when calling open, and then inject the data into the dialog component using the DIALOG_DATA injection token.

Another option is to set the inputs on the componentInstance after the dialog is opened, however if the component relies on the input being set before initialization, this can run into problems.

Angular 16 added the ability to pass in component @Inputs as in route params, which allows the removal of basic wrapper components and per-component boilerplate for the most common cases of passing in data through the Router. It would be nice to see this change also reflected in Dialog.

Use Case

  • Enables using an existing component that takes in @Input(s) in a basic Dialog without creating a wrapper dialog component that exists solely to pass along injected data (admittedly, of questionable value, since many dialogs will need dialog-specific UI/behavior)
  • Allows for passing in data to a dialog component in a more symmetric way with non-dialog components
  • Eliminates the need to create a dialog data specific interface for type-safe parameter passing to dialog components

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: material/dialogfeatureThis issue represents a new feature or feature request rather than a bug or bug fix

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions