feat(Dialog): Allow data to be a signal
- Dominant language
- TypeScript
- Stars
- 25k
- Forks
- 6.8k
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 91
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
Contributor guide
Research direction
Start by tracing the existing MAT_DIALOG_DATA injection path in the Angular Material dialog package and review how public APIs are exposed from @angular/material/dialog. Define the signal API and its expected behavior from the proposal, then add coverage for reading dialog data through the new function; done means the documented use case works without the manual inject-and-signal boilerplate.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, typescript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100