简体   繁体   English

如何从Angular Material中删除日期选择器的默认日期选择?

[英]How to remove default date selection of datepicker from Angular Material?

Okay, I do not know if this is possible, but the angular material datepicker selects the date of the day by default. 好的,我不知道这是否可行,但是默认情况下,棱角材料datepicker选择datepicker选择日期。 I would like no datepicker dates to be selected by default. 我不希望默认选择任何datepicker日期。

EDIT: This is only visual, no date is selected when closing but I would like the date of the day not to be visible as on the gif. 编辑:这只是视觉上的,关闭时没有选择日期,但是我希望当天的日期不像gif那样可见。

Here is the datepicker of angular material: Stackblitz HERE 这是角形材料的datepickerStackblitz HERE

在此处输入图片说明

Thank you in advance! 先感谢您!

I have been trying to help since a long time. 很久以来我一直在努力提供帮助。 I found a work around. 我找到了解决方法。 Not a perfect solution 并非完美的解决方案

You can include the following css 您可以包括以下CSS

::ng-deep .mat-calendar-body-today {
  border: none !important;
}

The above css is to remove the border of the current date. 上面的css是删除当前日期的边框。

I was trying to remove the highlighted part but could not. 我试图删除突出显示的部分,但无法删除。

I shared to give a insight on what can be done. 我分享了关于可以做什么的见解。

Please look at the stackblitz here 请在这里查看堆叠闪电战

It's not selecting it. 它没有选择它。 It shows you the current day. 它向您显示当前日期。 I don't think you can disable that. 我认为您不能禁用它。 If you get out of the datepicker, no date will be chosen. 如果您不使用日期选择器,则不会选择任何日期。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM