angular / angular/components

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

Abierto
#22,158 7 comentarios 0 reacciones 0 asignados Ver en GitHub
area: material/datepicker forms P3
Lenguaje dominante
TypeScript
Estrellas
25k
Forks
6.8k
Merge medio
1 d 8 h
PR fusionados (30 d)
91

Descripción

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

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Comienza con la reproducción vinculada de StackBlitz, especialmente con src/app/date-range-picker.ts, y sigue la suscripción a valueChanges de FormGroup de mat-date-range-picker durante la inicialización y las actualizaciones de los botones. Confirma si las emisiones repetidas son un error de Angular Material o un comportamiento esperado de los formularios reactivos; el issue no especifica un cambio de código concreto ni una prueba para completarlo.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
angular, typescript
Área
frontend
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Necesita aclaración
Aptitud para principiantes
25/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.