angular / angular/components

Allow mat-datepicker to return a string instead of a date object.

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

描述

#### Please describe the feature you would like to request.
Allow for the mat-datepicker to return a string, instead of a `Date` object.

#### What is the use-case or motivation for this proposal?
I am currently attempting to use mat-datepicker, with the Angular Form Builder. The only issue, is that mat-datepicker will return the selected value as a Date object instead of a string. This does not allow for the value to be immediately passed in from the mat-datepicker into a formGroup, and then sent as a request to the server without first converting it to a string. In an app that heavily uses date-picker it requires a new component to be built on top of mat-datepicker.

#### Is there anything else we should know?
The following is a [stackblitz](https://angular-material-nw1brd.stackblitz.io/), which re-iterates point that the mat-datepicker returns an object, instead of the expected string. You will have to open up console in order to see value.

If you have any recommendations on how to provide a value from a module side of things, so that mat-datepicker returns a string instead of a date object, it would be very much so appreciated. Thank you.

贡献指南

打开贡献指南

调研方向

从链接的 StackBlitz 中所示的 mat-datepicker 行为开始,追踪其选定值如何进入 Angular Form Builder 的 formGroup。在决定适用哪些完成和兼容性要求之前,先明确预期的字符串格式以及该更改是否应当可配置。

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

评估

技术栈
angular, typescript
领域
frontend
Issue 类型
功能
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
基本清楚
新手友好度
25/100

把新 issue 发到你的邮箱

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