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

Method _generateOptions

src/material/timepicker/timepicker.ts:405–427  ·  view source on GitHub ↗

Generates the list of options from which the user can select..

()

Source from the content-addressed store, hash-verified

403
404 /** Generates the list of options from which the user can select.. */
405 private _generateOptions(): void {
406 // Default the interval to 30 minutes.
407 const interval = this.interval() ?? 30 * 60;
408 const options = this.options();
409
410 if (options !== null) {
411 this._timeOptions = options;
412 } else {
413 const input = this._input();
414 const adapter = this._dateAdapter;
415 const timeFormat = this._dateFormats.display.timeInput;
416 const min = input?.min() || adapter.setTime(adapter.today(), 0, 0, 0);
417 const max = input?.max() || adapter.setTime(adapter.today(), 23, 59, 0);
418 const cacheKey =
419 interval + '/' + adapter.format(min, timeFormat) + '/' + adapter.format(max, timeFormat);
420
421 // Don't re-generate the options if the inputs haven't changed.
422 if (cacheKey !== this._optionsCacheKey) {
423 this._optionsCacheKey = cacheKey;
424 this._timeOptions = generateOptions(adapter, this._dateFormats, min, max, interval);
425 }
426 }
427 }
428
429 /**
430 * Synchronizes the internal state of the component based on a specific selected date.

Callers 2

openMethod · 0.95
_handleLocaleChangesMethod · 0.95

Calls 7

generateOptionsFunction · 0.90
optionsMethod · 0.45
minMethod · 0.45
setTimeMethod · 0.45
todayMethod · 0.45
maxMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected