Skip to content

Commit 9586b5c

Browse files
crisbetommalerba
authored andcommitted
docs(datepicker): add missing provider (#17259)
Adds `MAT_MOMENT_DATE_ADAPTER_OPTIONS` to the `deps` array in all the examples that use `MomentDateAdapter`. The token is technically an optional dependency, however people tend to copy things verbatim from the docs and they might miss that the token needs to be added (see #17235).
1 parent a306e93 commit 9586b5c

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

src/material-examples/material/datepicker/datepicker-formats/datepicker-formats-example.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {Component} from '@angular/core';
22
import {FormControl} from '@angular/forms';
3-
import {MomentDateAdapter} from '@angular/material-moment-adapter';
3+
import {MomentDateAdapter, MAT_MOMENT_DATE_ADAPTER_OPTIONS} from '@angular/material-moment-adapter';
44
import {DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE} from '@angular/material/core';
55

66
// Depending on whether rollup is used, moment needs to be imported differently.
@@ -36,7 +36,11 @@ export const MY_FORMATS = {
3636
// `MomentDateAdapter` can be automatically provided by importing `MomentDateModule` in your
3737
// application's root module. We provide it at the component level here, due to limitations of
3838
// our example generation script.
39-
{provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE]},
39+
{
40+
provide: DateAdapter,
41+
useClass: MomentDateAdapter,
42+
deps: [MAT_DATE_LOCALE, MAT_MOMENT_DATE_ADAPTER_OPTIONS]
43+
},
4044

4145
{provide: MAT_DATE_FORMATS, useValue: MY_FORMATS},
4246
],

src/material-examples/material/datepicker/datepicker-locale/datepicker-locale-example.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import {Component} from '@angular/core';
2-
import {MAT_MOMENT_DATE_FORMATS, MomentDateAdapter} from '@angular/material-moment-adapter';
2+
import {
3+
MAT_MOMENT_DATE_FORMATS,
4+
MomentDateAdapter,
5+
MAT_MOMENT_DATE_ADAPTER_OPTIONS,
6+
} from '@angular/material-moment-adapter';
37
import {DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE} from '@angular/material/core';
48

59
/** @title Datepicker with different locale */
@@ -15,7 +19,11 @@ import {DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE} from '@angular/material/
1519
// `MomentDateAdapter` and `MAT_MOMENT_DATE_FORMATS` can be automatically provided by importing
1620
// `MatMomentDateModule` in your applications root module. We provide it at the component level
1721
// here, due to limitations of our example generation script.
18-
{provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE]},
22+
{
23+
provide: DateAdapter,
24+
useClass: MomentDateAdapter,
25+
deps: [MAT_DATE_LOCALE, MAT_MOMENT_DATE_ADAPTER_OPTIONS]
26+
},
1927
{provide: MAT_DATE_FORMATS, useValue: MAT_MOMENT_DATE_FORMATS},
2028
],
2129
})

src/material-examples/material/datepicker/datepicker-views-selection/datepicker-views-selection-example.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {Component} from '@angular/core';
22
import {FormControl} from '@angular/forms';
3-
import {MomentDateAdapter} from '@angular/material-moment-adapter';
3+
import {MomentDateAdapter, MAT_MOMENT_DATE_ADAPTER_OPTIONS} from '@angular/material-moment-adapter';
44
import {DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE} from '@angular/material/core';
55
import {MatDatepicker} from '@angular/material/datepicker';
66

@@ -37,7 +37,11 @@ export const MY_FORMATS = {
3737
// `MomentDateAdapter` can be automatically provided by importing `MomentDateModule` in your
3838
// application's root module. We provide it at the component level here, due to limitations of
3939
// our example generation script.
40-
{provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE]},
40+
{
41+
provide: DateAdapter,
42+
useClass: MomentDateAdapter,
43+
deps: [MAT_DATE_LOCALE, MAT_MOMENT_DATE_ADAPTER_OPTIONS]
44+
},
4145

4246
{provide: MAT_DATE_FORMATS, useValue: MY_FORMATS},
4347
],

0 commit comments

Comments
 (0)