angular / angular/components

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

Đang mở
#22,158 7 bình luận 0 reaction 0 người được giao Xem trên GitHub
area: material/datepicker forms P3
Ngôn ngữ chính
TypeScript
Star
25k
Fork
6.8k
Merge trung bình
1 ngày 8 giờ
Pull request đã merge (30 ngày)
91

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu với bản tái hiện StackBlitz được liên kết, đặc biệt là src/app/date-range-picker.ts, và theo dõi subscription valueChanges của FormGroup trong mat-date-range-picker trong quá trình khởi tạo và cập nhật nút. Xác nhận liệu các lần phát lặp lại có phải là bug của Angular Material hay là hành vi được mong đợi của reactive form; issue không chỉ định thay đổi code cụ thể hoặc test để hoàn tất.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
angular, typescript
Lĩnh vực
frontend
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
25/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.