From fa3cf12aa8d97ea2c5c6e7a70546bf0a53a2c720 Mon Sep 17 00:00:00 2001 From: Sargo Darya Date: Wed, 2 Aug 2017 23:34:04 +0200 Subject: [PATCH] docs(datepicker): Add example for setLocale method (#6224) * docs(datepicker): Add example for setLocale method Add a usage example to show how the formatting locale of the datepicker can be be changed as that wasn't documented before. * docs(datepicker): Wording change for setLocale example --- src/lib/datepicker/datepicker.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/lib/datepicker/datepicker.md b/src/lib/datepicker/datepicker.md index 5ce1f6e3753..7f26cd90ff9 100644 --- a/src/lib/datepicker/datepicker.md +++ b/src/lib/datepicker/datepicker.md @@ -128,6 +128,22 @@ By default the datepicker will use the locale code from the `LOCALE_ID` injectio export class MyApp {} ``` +It's also possible to set the locale at runtime using the `setLocale` method of the `DateAdapter`. + +```ts +import { DateAdapter, NativeDateAdapter } from '@angular/material'; + +@Component({ + selector: 'foo', + template: '' +}) +export class FooComponent { + constructor(dateAdapter: DateAdapter) { + dateAdapter.setLocale('de-DE'); + } +} +``` + #### Choosing a date implementation and date format settings The datepicker was built to be date implementation agnostic. This means that it can be made to work with a variety of different date implementations. However it also means that developers need to make