本文介绍了如何在 mat-datepicker 上仅选择年份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,我正在开发一个 angular 8 的应用程序,其中我的输入仅包含年份编号.我使用过 mat-datepicker,只想选择年份.
Hello i'm developing an application with angular 8 in wich i have an input that contains only year number.I have used mat-datepicker and want only to choose year.
<mat-form-field class="input-control">
<input matInput placeholder="{{'enter'|translate}}.." [formControl]="form.controls.openedAt"
[matDatepicker]="date" readonly>
<mat-datepicker-toggle matSuffix [for]="date"></mat-datepicker-toggle>
<mat-datepicker #date startView="multi-year"></mat-datepicker>
</mat-form-field>
此代码首先显示年视图,但是当我选择年份时,将打开月视图,然后打开天视图.
this code shows year view first, but when i choose the year, the month view will be opened, then days view.
那么如何在 mat-datepicker 上仅选择年份或仅显示年份视图?
推荐答案
此功能尚未完全实现.你可以在这里看到:
This feature is not fully implemented yet. You can see that here:
https://github.com/angular/components/issues/4853
现在你可以试试这个:
https://stackblitz.com/edit/angular-mulitdate-picker-demo
这篇关于如何在 mat-datepicker 上仅选择年份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!