1
- import { Component , Inject } from '@angular/core' ;
1
+ import { Component , Inject , OnInit } from '@angular/core' ;
2
2
import {
3
3
MAT_MOMENT_DATE_FORMATS ,
4
4
MomentDateAdapter ,
@@ -11,6 +11,7 @@ import {MatInputModule} from '@angular/material/input';
11
11
import { MatFormFieldModule } from '@angular/material/form-field' ;
12
12
import 'moment/locale/ja' ;
13
13
import 'moment/locale/fr' ;
14
+ import { MatDatepickerIntl } from '@angular/material/datepicker' ;
14
15
15
16
/** @title Datepicker with different locale */
16
17
@Component ( {
@@ -34,15 +35,26 @@ import 'moment/locale/fr';
34
35
standalone : true ,
35
36
imports : [ MatFormFieldModule , MatInputModule , MatDatepickerModule , MatButtonModule ] ,
36
37
} )
37
- export class DatepickerLocaleExample {
38
+ export class DatepickerLocaleExample implements OnInit {
38
39
constructor (
39
40
private _adapter : DateAdapter < any > ,
41
+ private _intl : MatDatepickerIntl ,
40
42
@Inject ( MAT_DATE_LOCALE ) private _locale : string ,
41
43
) { }
42
44
45
+ ngOnInit ( ) {
46
+ this . updateCloseButtonLabel ( 'カレンダーを閉じる' ) ;
47
+ }
48
+
43
49
french ( ) {
44
50
this . _locale = 'fr' ;
45
51
this . _adapter . setLocale ( this . _locale ) ;
52
+ this . updateCloseButtonLabel ( 'Fermer le calendrier' ) ;
53
+ }
54
+
55
+ updateCloseButtonLabel ( label : string ) {
56
+ this . _intl . closeCalendarLabel = label ;
57
+ this . _intl . changes . next ( ) ;
46
58
}
47
59
48
60
getDateFormatString ( ) : string {
0 commit comments