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

Method getLabel

src/material/menu/menu-item.ts:164–177  ·  view source on GitHub ↗

Gets the label to be used when determining whether the option should be focused.

()

Source from the content-addressed store, hash-verified

162
163 /** Gets the label to be used when determining whether the option should be focused. */
164 getLabel(): string {
165 const clone = this._elementRef.nativeElement.cloneNode(true) as HTMLElement;
166 const icons = clone.querySelectorAll(
167 'mat-icon, .material-icons, .material-symbols-outlined, ' +
168 '.material-symbols-rounded, .material-symbols-sharp',
169 );
170
171 // Strip away icons, so they don't show up in the text.
172 for (let i = 0; i < icons.length; i++) {
173 icons[i].remove();
174 }
175
176 return clone.textContent?.trim() || '';
177 }
178
179 _setHighlighted(isHighlighted: boolean) {
180 // We need to mark this for check for the case where the content is coming from a

Callers

nothing calls this directly

Calls 1

removeMethod · 0.65

Tested by

no test coverage detected