更改Angular单场单场的选择日期选择器格式
As you can see I have already changed the opening Date date-picker format bu,
I want to change year built format to Year(YYYY) only while keeping other form fields intact.
is it possible to do that?
or any references.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Angular材料提供MAT_DATE_FORMATS对象,该对象是DatePicker使用的格式集合,用于解析和显示日期。要使用自定义日期格式,我们需要使用给定格式覆盖MAT_DATE_FORMATS。导入并提供您自己的日期格式。
根据需要以自定义方式定义日期格式。
在@component中,添加提供商
Angular Material provides MAT_DATE_FORMATS object which is the collection of formats used by Datepicker to parse and display dates. To use custom date format we need to override MAT_DATE_FORMATS with the given formats. Import it and provide your own date format.
Define a date format in a custom way as you require.
In @Component, add the provider