MCPcopy Create free account
hub / github.com/angular/components / _init

Method _init

src/material/datepicker/multi-year-view.ts:179–202  ·  view source on GitHub ↗

Initializes this multi-year view.

()

Source from the content-addressed store, hash-verified

177
178 /** Initializes this multi-year view. */
179 _init() {
180 this._todayYear.set(this._dateAdapter.getYear(this._dateAdapter.today()));
181
182 // We want a range years such that we maximize the number of
183 // enabled dates visible at once. This prevents issues where the minimum year
184 // is the last item of a page OR the maximum year is the first item of a page.
185
186 // The offset from the active year to the "slot" for the starting year is the
187 // *actual* first rendered year in the multi-year view.
188 const activeYear = this._dateAdapter.getYear(this._activeDate);
189 const minYearOfPage =
190 activeYear - getActiveOffset(this._dateAdapter, this.activeDate, this.minDate, this.maxDate);
191
192 const years: MatCalendarCell[][] = [];
193 for (let i = 0, row: number[] = []; i < yearsPerPage; i++) {
194 row.push(minYearOfPage + i);
195 if (row.length == yearsPerRow) {
196 years.push(row.map(year => this._createCellForYear(year)));
197 row = [];
198 }
199 }
200 this._years.set(years);
201 this._changeDetectorRef.markForCheck();
202 }
203
204 /** Handles when a new year is selected. */
205 _yearSelected(event: MatCalendarUserEvent<number>) {

Callers 2

activeDateMethod · 0.95
ngAfterContentInitMethod · 0.95

Calls 7

_createCellForYearMethod · 0.95
getActiveOffsetFunction · 0.85
setMethod · 0.80
markForCheckMethod · 0.80
pushMethod · 0.65
getYearMethod · 0.45
todayMethod · 0.45

Tested by

no test coverage detected