Skip to content

Commit 7d712e0

Browse files
committed
use MAT_DATE_LOCALE
1 parent 511770f commit 7d712e0

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/material-moment-adapter/adapter/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
import {NgModule} from '@angular/core';
10-
import {DateAdapter, MD_DATE_FORMATS} from '@angular/material';
10+
import {DateAdapter, MAT_DATE_LOCALE_PROVIDER, MD_DATE_FORMATS} from '@angular/material';
1111
import {MomentDateAdapter} from './moment-date-adapter';
1212
import {MD_MOMENT_DATE_FORMATS} from './moment-date-formats';
1313

@@ -16,7 +16,10 @@ export * from './moment-date-formats';
1616

1717

1818
@NgModule({
19-
providers: [{provide: DateAdapter, useClass: MomentDateAdapter}],
19+
providers: [
20+
MAT_DATE_LOCALE_PROVIDER,
21+
{provide: DateAdapter, useClass: MomentDateAdapter}
22+
],
2023
})
2124
export class MomentDateModule {}
2225

src/material-moment-adapter/adapter/moment-date-adapter.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
import {Inject, Injectable, LOCALE_ID, Optional} from '@angular/core';
10-
import {DateAdapter} from '@angular/material';
10+
import {DateAdapter, MAT_DATE_LOCALE, MAT_DATE_LOCALE_PROVIDER} from '@angular/material';
1111
import * as moment from 'moment';
1212

1313

@@ -33,9 +33,9 @@ export class MomentDateAdapter extends DateAdapter<moment.Moment> {
3333
narrowDaysOfWeek: string[]
3434
};
3535

36-
constructor(@Optional() @Inject(LOCALE_ID) localeId: any) {
36+
constructor(@Optional() @Inject(MAT_DATE_LOCALE) dateLocale: string) {
3737
super();
38-
this.setLocale(localeId || moment.locale());
38+
this.setLocale(dateLocale || moment.locale());
3939
}
4040

4141
setLocale(locale: any) {

0 commit comments

Comments
 (0)