angular / angular/components

feat(Dialog): Allow data to be a signal

Offen
#28,848 2 Kommentare 11 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
area: material/dialog feature P4
Vorherrschende Sprache
TypeScript
Sterne
25k
Forks
6.8k
Ø Merge
1 T. 8 Std.
Gemergte PRs (30 T.)
91

Beschreibung

### 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

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne damit, den bestehenden MAT_DIALOG_DATA-Injektionspfad im Angular Material-Dialogpaket nachzuverfolgen, und prüfe, wie öffentliche APIs aus @angular/material/dialog bereitgestellt werden. Definiere die Signal-API und ihr erwartetes Verhalten anhand des Vorschlags und füge Abdeckung für das Lesen von Dialogdaten über die neue Funktion hinzu; fertig ist die Aufgabe, wenn der dokumentierte Anwendungsfall ohne das manuelle Inject-and-Signal-Boilerplate funktioniert.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
angular, typescript
Bereich
frontend
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
30/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.