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

Method _dateSelected

src/material/datepicker/month-view.ts:257–277  ·  view source on GitHub ↗

Handles when a new date is selected.

(event: MatCalendarUserEvent<number>)

Source from the content-addressed store, hash-verified

255
256 /** Handles when a new date is selected. */
257 _dateSelected(event: MatCalendarUserEvent<number>) {
258 const date = event.value;
259 const selectedDate = this._getDateFromDayOfMonth(date);
260 let rangeStartDate: number | null;
261 let rangeEndDate: number | null;
262
263 if (this._selected instanceof DateRange) {
264 rangeStartDate = this._getDateInCurrentMonth(this._selected.start);
265 rangeEndDate = this._getDateInCurrentMonth(this._selected.end);
266 } else {
267 rangeStartDate = rangeEndDate = this._getDateInCurrentMonth(this._selected);
268 }
269
270 if (rangeStartDate !== date || rangeEndDate !== date) {
271 this.selectedChange.emit(selectedDate);
272 }
273
274 this._userSelection.emit({value: selectedDate, event: event.event});
275 this._clearPreview();
276 this._changeDetectorRef.markForCheck();
277 }
278
279 /**
280 * Takes the index of a calendar body cell wrapped in an event as argument. For the date that

Callers 1

Calls 4

_clearPreviewMethod · 0.95
markForCheckMethod · 0.80

Tested by

no test coverage detected