feat(Dialog): Allow data to be a signal
- Langage dominant
- TypeScript
- Étoiles
- 25k
- Forks
- 6.8k
- Merge moyen
- 1 j 8 h
- PR mergées (30 j)
- 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
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Commencez par suivre le chemin d’injection existant de MAT_DIALOG_DATA dans le package de boîtes de dialogue Angular Material et examinez comment les API publiques sont exposées depuis @angular/material/dialog. Définissez l’API de signal et son comportement attendu à partir de la proposition, puis ajoutez une couverture pour la lecture des données de la boîte de dialogue via la nouvelle fonction ; le travail est terminé lorsque le cas d’utilisation documenté fonctionne sans le boilerplate manuel d’inject-and-signal.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- angular, typescript
- Domaine
- frontend
- Type d'issue
- Fonctionnalité
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 30/100