@@ -144,16 +144,6 @@ export class MatMonthView<D> implements AfterContentInit {
144
144
throw createMissingDateImplError ( 'MAT_DATE_FORMATS' ) ;
145
145
}
146
146
147
- const firstDayOfWeek = this . _dateAdapter . getFirstDayOfWeek ( ) ;
148
- const narrowWeekdays = this . _dateAdapter . getDayOfWeekNames ( 'narrow' ) ;
149
- const longWeekdays = this . _dateAdapter . getDayOfWeekNames ( 'long' ) ;
150
-
151
- // Rotate the labels for days of the week based on the configured first day of the week.
152
- let weekdays = longWeekdays . map ( ( long , i ) => {
153
- return { long, narrow : narrowWeekdays [ i ] } ;
154
- } ) ;
155
- this . _weekdays = weekdays . slice ( firstDayOfWeek ) . concat ( weekdays . slice ( 0 , firstDayOfWeek ) ) ;
156
-
157
147
this . _activeDate = this . _dateAdapter . today ( ) ;
158
148
}
159
149
@@ -252,6 +242,7 @@ export class MatMonthView<D> implements AfterContentInit {
252
242
( DAYS_PER_WEEK + this . _dateAdapter . getDayOfWeek ( firstOfMonth ) -
253
243
this . _dateAdapter . getFirstDayOfWeek ( ) ) % DAYS_PER_WEEK ;
254
244
245
+ this . _initWeekdays ( ) ;
255
246
this . _createWeekCells ( ) ;
256
247
this . _changeDetectorRef . markForCheck ( ) ;
257
248
}
@@ -261,6 +252,19 @@ export class MatMonthView<D> implements AfterContentInit {
261
252
this . _matCalendarBody . _focusActiveCell ( ) ;
262
253
}
263
254
255
+ /** Initializes the weekdays. */
256
+ private _initWeekdays ( ) {
257
+ const firstDayOfWeek = this . _dateAdapter . getFirstDayOfWeek ( ) ;
258
+ const narrowWeekdays = this . _dateAdapter . getDayOfWeekNames ( 'narrow' ) ;
259
+ const longWeekdays = this . _dateAdapter . getDayOfWeekNames ( 'long' ) ;
260
+
261
+ // Rotate the labels for days of the week based on the configured first day of the week.
262
+ let weekdays = longWeekdays . map ( ( long , i ) => {
263
+ return { long, narrow : narrowWeekdays [ i ] } ;
264
+ } ) ;
265
+ this . _weekdays = weekdays . slice ( firstDayOfWeek ) . concat ( weekdays . slice ( 0 , firstDayOfWeek ) ) ;
266
+ }
267
+
264
268
/** Creates MatCalendarCells for the dates in this month. */
265
269
private _createWeekCells ( ) {
266
270
const daysInMonth = this . _dateAdapter . getNumDaysInMonth ( this . activeDate ) ;
0 commit comments