Skip to content

Commit fa3cf12

Browse files
SargoDaryatinayuangao
authored andcommitted
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
1 parent f19d2e5 commit fa3cf12

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/lib/datepicker/datepicker.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,22 @@ By default the datepicker will use the locale code from the `LOCALE_ID` injectio
128128
export class MyApp {}
129129
```
130130

131+
It's also possible to set the locale at runtime using the `setLocale` method of the `DateAdapter`.
132+
133+
```ts
134+
import { DateAdapter, NativeDateAdapter } from '@angular/material';
135+
136+
@Component({
137+
selector: 'foo',
138+
template: ''
139+
})
140+
export class FooComponent {
141+
constructor(dateAdapter: DateAdapter<NativeDateAdapter>) {
142+
dateAdapter.setLocale('de-DE');
143+
}
144+
}
145+
```
146+
131147
#### Choosing a date implementation and date format settings
132148
The datepicker was built to be date implementation agnostic. This means that it can be made to work
133149
with a variety of different date implementations. However it also means that developers need to make

0 commit comments

Comments
 (0)