如何只选择日期的年份 [英] How to select only year on mat-datepicker

查看:139
本文介绍了如何只选择日期的年份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在开发角度为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上仅显示年份视图?

So how can i select only year, or show only year view on 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

这篇关于如何只选择日期的年份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆