angular - 如何使角度材料日期选择器仅选择年份?
问题描述
嗨,我正在使用角度材料 DatePicker https://material.angular.io/components/datepicker/examples,我只需要选择年份,我该如何正确执行此操作?这就是我所做的:
<div class="form-group row">
<label class="col-xl-3 col-lg-3 col-form-label">Production Year</label>
<div class="col-lg-9 col-xl-8">
<mat-form-field>
<input matInput [matDatepicker]="productionYearPicker" placeholder="Choose a date"
formControlName="productionYear"
[class.is-invalid]="isControlInvalid('productionYear')"
[class.is-valid]="isControlValid('productionYear')">
<mat-datepicker-toggle matSuffix [for]="productionYearPicker"></mat-datepicker-toggle>
<mat-datepicker #productionYearPicker startView="multi-year"></mat-datepicker>
</mat-form-field>
</div>
</div>
datePicker 可以从年份开始,但我仍然必须选择月份,并且在输入框中,当我只输入年份时,它会自动将其格式化为 1 月 1 日,我怎样才能禁用月份和日期?我只需要年份选择器
解决方案
推荐阅读
- c++ - 为表示一个或多个操作的 C++ 函数查找 int 参数的类型安全替换
- git - 在drupal 8中安装模块时作曲家抛出git错误
- typescript - 将类型分配给可能不需要解析的 JSON 类型
- java - 活动中的 Android 工作室名称选项卡
- sql - 我可以合并或加入这些表吗?
- c# - 如何在 ASP.NET 中使用视图模型?
- php - 即使 WP_DEBUG=true,Wordpress 也不会写入 debug.log
- quill - Quill:如何获取包含样式的 html 数据?
- python - 当您在 if 逻辑语句中调用修改函数时,是否会编辑 2D 列表?
- javascript - 如何使用 Javascript 本地存储从 HTML 文本框中存储值?