本文介绍了MAT_DATE_FORMATS 字段的定义/含义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 解析:{dateInput: 'DD.MM.YYYY',},展示: {dateInput: 'DD.MM.YYYY',monthYearLabel: 'MMM YYYY',dateA11yLabel: 'LL',monthYearA11yLabel: 'MMMM-YYYY',},

  • with parse.dateInput:您可以让用户以任何格式输入任何类型的日期,日期适配器会将其重新格式化为您在此属性中指定的格式

  • 使用display.dateInput可以指定输入日期格式(标有1)

  • display.monthYearLabel 可以指定标有2的区域

不幸的是,我仍然不知道其余的!

Material example for customizing-the-parse-and-display-formats for date picker uses custom MAT_DATE_FORMATS

export const MY_FORMATS = {
  parse: {
    dateInput: 'LL',
  },
  display: {
    dateInput: 'LL',
    monthYearLabel: 'MMM YYYY',
    dateA11yLabel: 'LL',
    monthYearA11yLabel: 'MMMM YYYY',
  },
};

I could not find where and how these fields like dateA11yLabel will come into play. What I could figure out was display.dateInput is used in displaying selected date on calendar and display.monthYearLabel is used in the select drop-down of year selector.

  1. Where are rest of the fields used?
  2. When writing custom MAT_DATE_FORMATS is it mandatory to define allfields?
解决方案

Well, I figured out the following:

 parse: {

    dateInput: 'DD.MM.YYYY',
  },
  display: {

    dateInput: 'DD.MM.YYYY',
    monthYearLabel: 'MMM YYYY',
    dateA11yLabel: 'LL',
    monthYearA11yLabel: 'MMMM-YYYY',
  },

  • with parse.dateInput: you can let the user enter any type of date with any format, and the date adapter will reformat it to the format you specify in this attribute

  • with display.dateInput you can specify the input date format (marked with 1)

  • display.monthYearLabel you can specify the area marked with 2

unfortunately, I still don't know about the rest!

这篇关于MAT_DATE_FORMATS 字段的定义/含义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 14:31