angular / angular/components

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

未关闭
#22,158 7 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
area: material/datepicker forms P3
主要语言
TypeScript
星标
25k
派生
6.8k
平均合并
1 天 8 小时
30 天内合并 PR
91

描述

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

贡献指南

打开贡献指南

调研方向

从链接的 StackBlitz 复现开始,尤其检查 src/app/date-range-picker.ts,并跟踪 mat-date-range-picker FormGroup valueChanges 订阅在初始化和按钮更新期间的情况。确认重复发射是 Angular Material 的 bug,还是响应式表单的预期行为;该 issue 未指定具体的代码更改或用于完成的测试。

由索引模型根据 Issue 内容生成。

评估

技术栈
angular, typescript
领域
frontend
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
需要澄清
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。