Skip to content

docs(datepicker): Add example for setLocale method #6224

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 2, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/lib/datepicker/datepicker.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<NativeDateAdapter>) {
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
Expand Down