Skip to content

feat(Dialog): Allow data to be a signal #28848

Open
@spock123

Description

@spock123

Feature Description

Currently, to access data inside a material component, and treat it as a signal, we have to inject MAT_DIALOG_DATA and get the data like this:

import { MAT_DIALOG_DATA } from '@angular/components/dialog';

data =signal( inject(MAT_DIALOG_DATA)) // create signal from input data

ngOnInit() {
    // Do something with the data
}

Proposal:

Create a new function that injects MAT_DIALOG_DATA for us, and returns the injected data as a signal:

import { dialogData } from '@angular/material/dialog' // new function

data = dialogData(); // data is now a signal

doSomething = effect( () => dosomethingWithhdata( this.data());

Use Case

Having data inputs for dialogs handled in the same way as regular components, and having the inputs available as signals without needing the boilerplate code we currently need to do.

Having inputs as signals also lets us avoid using ngOnInit and constructors because it lets us use effect() to initiate actions

Metadata

Metadata

Assignees

No one assigned

    Labels

    P4A relatively minor issue that is not relevant to core functionsarea: 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