-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Open
Labels
P4A relatively minor issue that is not relevant to core functionsA 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 fixThis issue represents a new feature or feature request rather than a bug or bug fix
Description
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
jase88, craiggoldstone, stianmorsund, R0DR160HM, artaommahe and 5 more
Metadata
Metadata
Assignees
Labels
P4A relatively minor issue that is not relevant to core functionsA 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 fixThis issue represents a new feature or feature request rather than a bug or bug fix