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

Method _updateInternalValue

src/cdk/listbox/listbox.ts:924–935  ·  view source on GitHub ↗

Update the internal value of the listbox based on the selection model.

()

Source from the content-addressed store, hash-verified

922
923 /** Update the internal value of the listbox based on the selection model. */
924 private _updateInternalValue() {
925 const indexCache = new Map<T, number>();
926 this.selectionModel.sort((a: T, b: T) => {
927 const aIndex = this._getIndexForValue(indexCache, a);
928 const bIndex = this._getIndexForValue(indexCache, b);
929 return aIndex - bIndex;
930 });
931 const selected = this.selectionModel.selected;
932 this._invalid =
933 (!this.multiple && selected.length > 1) || !!this._getInvalidOptionValues(selected).length;
934 this.changeDetectorRef.markForCheck();
935 }
936
937 /**
938 * Gets the index of the given value in the given list of options.

Callers 2

multipleMethod · 0.95
ngAfterContentInitMethod · 0.95

Calls 4

_getIndexForValueMethod · 0.95
markForCheckMethod · 0.80
sortMethod · 0.65

Tested by

no test coverage detected