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

Method _setSelected

src/material/list/list-option.ts:270–286  ·  view source on GitHub ↗

* Sets the selected state of the option. * @returns Whether the value has changed.

(selected: boolean)

Source from the content-addressed store, hash-verified

268 * @returns Whether the value has changed.
269 */
270 _setSelected(selected: boolean): boolean {
271 if (selected === this._selected) {
272 return false;
273 }
274
275 this._selected = selected;
276
277 if (selected) {
278 this._selectionList.selectedOptions.select(this);
279 } else {
280 this._selectionList.selectedOptions.deselect(this);
281 }
282
283 this.selectedChange.emit(selected);
284 this._changeDetectorRef.markForCheck();
285 return true;
286 }
287
288 /**
289 * Notifies Angular that the option needs to be checked in the next change detection run.

Callers 4

selectedMethod · 0.95
ngOnInitMethod · 0.95
_setOptionsFromValuesMethod · 0.80

Calls 3

markForCheckMethod · 0.80
selectMethod · 0.65
deselectMethod · 0.65

Tested by

no test coverage detected