angular / angular/components

help(mat-date-range-picker): Getting date range values from Reactive FormGroup

Aperta
#22,158 7 commenti 0 reazioni 0 assegnatari Vedi su GitHub
area: material/datepicker forms P3
Lingua principale
TypeScript
Stelle
25k
Fork
6.8k
Merge medio
1g 8h
PR unite (30g)
91

Descrizione

#### What are you trying to do?

I would like to use the date range picker in a reactive form and emit an event when the FormGroup's value changes.

I'm subscribing to the valueChanges Observable on the FormGroup and emitting an event when a value changes.

#### What troubleshooting steps have you tried?

I am seeing many events being emitted when the FormGroup is initialized (4x). And when the form control's value is modified at runtime via button click there are even more events emitted.

Is a way to filter down the valueChange events coming from the FormGroup? I realize I could filter the values coming through the valueChange Observable but I'm not sure how to know which value is the one I'm after.

#### Reproduction
https://stackblitz.com/edit/date-time-picker-reactive-form?file=src/app/date-range-picker.ts

#### Environment

- Angular: 10.2.4
- CDK/Material: 10.2.7
- Browser(s): Chrome
- Operating System (e.g. Windows, macOS, Ubuntu): Windows

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia dalla riproduzione StackBlitz collegata, in particolare da src/app/date-range-picker.ts, e traccia la sottoscrizione a valueChanges di FormGroup di mat-date-range-picker durante l’inizializzazione e gli aggiornamenti dei pulsanti. Verifica se le emissioni ripetute sono un bug di Angular Material o il comportamento previsto dei form reattivi; l’issue non specifica una modifica concreta al codice né un test per il completamento.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
angular, typescript
Ambito
frontend
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.