我在@NgModule中为ng-pick-datetime(5.1.5)提到了提供:OWL_DATE_TIME_LOCALE,useValue:日期格式的'en-SG'。当我们直接从触发器打开日历时,效果很好。但是,如果直接与输入框进行交互,然后打开日历,它将更改为默认格式。
import {OWL_DATE_TIME_LOCALE , OwlDateTimeModule, OwlNativeDateTimeModule} from 'ng-pick-datetime';
@NgModule({
declarations: [ParcelCreateComponent],
imports: [
OwlDateTimeModule,OwlNativeDateTimeModule
],
providers: [{provide: OWL_DATE_TIME_LOCALE, useValue: 'en-SG'}]
})
最佳答案
import { NgModule } from '@angular/core';import { OwlDateTimeModule, OWL_DATE_TIME_FORMATS} from 'ng-pick-datetime';import { OwlMomentDateTimeModule } from 'ng-pick-datetime-moment'; // See the Moment.js docs for the meaning of these formats:// https://momentjs.com/docs/#/displaying/format/export const MY_MOMENT_FORMATS = { parseInput: 'l LT', fullPickerInput: 'l LT', datePickerInput: 'l', timePickerInput: 'LT', monthYearLabel: 'MMM YYYY', dateA11yLabel: 'LL', monthYearA11yLabel: 'MMMM YYYY',}; @NgModule({ imports: [OwlDateTimeModule, OwlMomentDateTimeModule], providers: [ {provide: OWL_DATE_TIME_FORMATS, useValue: MY_MOMENT_FORMATS}, ],})export class AppExampleModule {}
关于datetime - Angular 5 ng-pick-datetime日期格式,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/48702408/