如何在 Angular 中创建月和日日期选择器,不包括隐藏年份?
此以下链接将执行月份和年份选择器。我试图操纵它,做月和日。用 DD 替换 YYYY 不起作用。
闪电战:
https://stackblitz.com/angular/gxymgjpprdy?file=src%2Fapp%2Fdatepicker-views-selection-example.ts
来自 Stackblitz 的真实代码:
打字稿:
import {Component} from '@angular/core';
import {FormControl} from '@angular/forms';
import {MomentDateAdapter, MAT_MOMENT_DATE_ADAPTER_OPTIONS} from '@angular/material-moment-adapter';
import {DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE} from '@angular/material/core';
import {MatDatepicker} from '@angular/material/datepicker';
// Depending on whether rollup is used, moment needs to be imported differently.
// Since Moment.js doesn't have a default export, we normally need to import using the `* as`
// syntax. However, rollup creates a synthetic default module and we thus need …Run Code Online (Sandbox Code Playgroud)