I'm using MatMomentDateModule for Angular Material's matDatePicker component. But this imports all locales for Moment.js even though I need only one:
Is there a way to tell it to only import the locales I need?
In my module I import it like:
import { MatDatepickerModule } from '@angular/material';
import { MatMomentDateModule } from '@angular/material-moment-adapter';
@NgModule({
declarations: [],
imports: [
...
MatDatepickerModule,
MatMomentDateModule,
...
],
exports: [
...
MatDatepickerModule,
MatMomentDateModule,
...
]
})
export class MaterialModule {}
You can try specify it in your Providers array of app.module.ts?
@NgModule({
providers: [
{provide: MAT_DATE_LOCALE, useValue: 'en-GB'},
],
})
export class MyApp {}
See link: https://material.angular.io/components/datepicker/overview#setting-the-locale-code
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.