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

Class VersionPicker

docs/src/app/shared/version-picker/version-picker.ts:33–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31 changeDetection: ChangeDetectionStrategy.Eager,
32})
33export class VersionPicker {
34 private readonly _versions = httpResource<VersionInfo[]>(() => versionUrl);
35
36 /** The currently running version of Material. */
37 materialVersion = normalizedMaterialVersion;
38 /** The possible versions of the doc site. Empty if they couldn't be loaded. */
39 readonly docVersions = computed(() => (this._versions.hasValue() ? this._versions.value() : []));
40
41 /**
42 * Updates the window location if the selected version is a different version.
43 * @param version data for use in navigating to the version's path
44 */
45 onVersionChanged(version: VersionInfo) {
46 if (!version.url.startsWith(window.location.origin)) {
47 window.location.assign(
48 window.location.pathname
49 ? version.url + window.location.pathname + window.location.hash
50 : version.url,
51 );
52 }
53 }
54}

Callers

nothing calls this directly

Calls 3

computedFunction · 0.85
hasValueMethod · 0.80
valueMethod · 0.45

Tested by

no test coverage detected