From c39e8b2aebaa97ccc40dcd159d6224453cc97951 Mon Sep 17 00:00:00 2001 From: crisbeto Date: Tue, 1 Oct 2019 21:09:46 +0200 Subject: [PATCH] docs(datepicker): add missing provider 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). --- .../datepicker-formats/datepicker-formats-example.ts | 8 ++++++-- .../datepicker-locale/datepicker-locale-example.ts | 12 ++++++++++-- .../datepicker-views-selection-example.ts | 8 ++++++-- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/material-examples/material/datepicker/datepicker-formats/datepicker-formats-example.ts b/src/material-examples/material/datepicker/datepicker-formats/datepicker-formats-example.ts index d529f3cc8239..c34320e70d94 100644 --- a/src/material-examples/material/datepicker/datepicker-formats/datepicker-formats-example.ts +++ b/src/material-examples/material/datepicker/datepicker-formats/datepicker-formats-example.ts @@ -1,6 +1,6 @@ import {Component} from '@angular/core'; import {FormControl} from '@angular/forms'; -import {MomentDateAdapter} from '@angular/material-moment-adapter'; +import {MomentDateAdapter, MAT_MOMENT_DATE_ADAPTER_OPTIONS} from '@angular/material-moment-adapter'; import {DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE} from '@angular/material/core'; // Depending on whether rollup is used, moment needs to be imported differently. @@ -36,7 +36,11 @@ export const MY_FORMATS = { // `MomentDateAdapter` can be automatically provided by importing `MomentDateModule` in your // application's root module. We provide it at the component level here, due to limitations of // our example generation script. - {provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE]}, + { + provide: DateAdapter, + useClass: MomentDateAdapter, + deps: [MAT_DATE_LOCALE, MAT_MOMENT_DATE_ADAPTER_OPTIONS] + }, {provide: MAT_DATE_FORMATS, useValue: MY_FORMATS}, ], diff --git a/src/material-examples/material/datepicker/datepicker-locale/datepicker-locale-example.ts b/src/material-examples/material/datepicker/datepicker-locale/datepicker-locale-example.ts index fc4af21698c9..9ef3c3fdee5a 100644 --- a/src/material-examples/material/datepicker/datepicker-locale/datepicker-locale-example.ts +++ b/src/material-examples/material/datepicker/datepicker-locale/datepicker-locale-example.ts @@ -1,5 +1,9 @@ import {Component} from '@angular/core'; -import {MAT_MOMENT_DATE_FORMATS, MomentDateAdapter} from '@angular/material-moment-adapter'; +import { + MAT_MOMENT_DATE_FORMATS, + MomentDateAdapter, + MAT_MOMENT_DATE_ADAPTER_OPTIONS, +} from '@angular/material-moment-adapter'; import {DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE} from '@angular/material/core'; /** @title Datepicker with different locale */ @@ -15,7 +19,11 @@ import {DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE} from '@angular/material/ // `MomentDateAdapter` and `MAT_MOMENT_DATE_FORMATS` can be automatically provided by importing // `MatMomentDateModule` in your applications root module. We provide it at the component level // here, due to limitations of our example generation script. - {provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE]}, + { + provide: DateAdapter, + useClass: MomentDateAdapter, + deps: [MAT_DATE_LOCALE, MAT_MOMENT_DATE_ADAPTER_OPTIONS] + }, {provide: MAT_DATE_FORMATS, useValue: MAT_MOMENT_DATE_FORMATS}, ], }) diff --git a/src/material-examples/material/datepicker/datepicker-views-selection/datepicker-views-selection-example.ts b/src/material-examples/material/datepicker/datepicker-views-selection/datepicker-views-selection-example.ts index cf4c158ddcfc..186eb7d293dc 100644 --- a/src/material-examples/material/datepicker/datepicker-views-selection/datepicker-views-selection-example.ts +++ b/src/material-examples/material/datepicker/datepicker-views-selection/datepicker-views-selection-example.ts @@ -1,6 +1,6 @@ import {Component} from '@angular/core'; import {FormControl} from '@angular/forms'; -import {MomentDateAdapter} from '@angular/material-moment-adapter'; +import {MomentDateAdapter, MAT_MOMENT_DATE_ADAPTER_OPTIONS} from '@angular/material-moment-adapter'; import {DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE} from '@angular/material/core'; import {MatDatepicker} from '@angular/material/datepicker'; @@ -37,7 +37,11 @@ export const MY_FORMATS = { // `MomentDateAdapter` can be automatically provided by importing `MomentDateModule` in your // application's root module. We provide it at the component level here, due to limitations of // our example generation script. - {provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE]}, + { + provide: DateAdapter, + useClass: MomentDateAdapter, + deps: [MAT_DATE_LOCALE, MAT_MOMENT_DATE_ADAPTER_OPTIONS] + }, {provide: MAT_DATE_FORMATS, useValue: MY_FORMATS}, ],