angular / angular/components

Change datepicker parse and display format at runtime

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

描述

#### Bug, feature request, or proposal:
Currently the parse and display format of a datepicker can only be set before runtime by providing them with ```provide: MAT_DATE_FORMATS, useValue: MY_DATE_FORMATS```.
As shown in the example: https://material.angular.io/components/datepicker/examples

#### What is the expected behavior?
The parse and display format of the datepicker should also be able to be changed at runtime, the same way it's possible to change the locale at runtime with ```.setLocale()```.
Maybe add ```.setDateFormat(MY_DATE_FORMAT_GENERATED_AT_RUNTIME)```, as sometimes the date format is only available after a HTTP request to the server.

#### What is the current behavior?
Date format is set in provider and cannot be changed at runtime.

#### What is the use-case or motivation for changing an existing behavior?
It should be possible to change the date format at runtime, to be able to react to date-formats, set by the backend. The user can set a preferred date format in the application and the application has to retrieve it from the server and adjust the datepicker accordingly. This is currently not possible.

贡献指南

打开贡献指南

调研方向

从 Angular Material 的 datepicker 示例和 issue 中展示的 MAT_DATE_FORMATS provider 开始,然后跟踪 setLocale() 如何改变 datepicker 的行为。定义并验证一种运行时机制,以便在收到服务器响应后更新解析格式和显示格式,包括格式发生变化时的预期行为。

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

评估

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

把新 issue 发到你的邮箱

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