mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
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
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user