0
カスタム日付アダプタを適用しました。しかし、ピッカーを開くと、現在の月が表示ビューになります。ここでAngular2 Material日付ピッカーポップアップを開くときにDD-MM-YYYY形式を使用した日付ピッカーの問題
は私のコードです:
export class MyDateAdapter extends NativeDateAdapter {
format(date: Date, displayFormat: Object): string {
if (displayFormat === 'input') {
const day = date.getDate();
const month = date.getMonth() + 1;
const year = date.getFullYear();
return `${day}-${month}-${year}`;
} else {
return date.toDateString();
}
}
}
const MY_DATE_FORMATS = {
parse: {
dateInput: 'dd-mm-YYYY',// { month: 'short', year: 'numeric', day: 'numeric' },
},
display: {
dateInput: 'input',
monthYearLabel: { year: 'numeric', month: 'numeric' },
dateA11yLabel: { year: 'numeric', month: 'long', day: 'numeric' },
monthYearA11yLabel: { year: 'numeric', month: 'long' },
},
};
{ provide: DateAdapter, useClass: MyDateAdapter },
{ provide: MD_DATE_FORMATS, useValue: MY_DATE_FORMATS },