MCPcopy
hub / github.com/angular/components / getId

Method getId

src/cdk/a11y/id-generator.ts:31–48  ·  view source on GitHub ↗

* Generates a unique ID with a specific prefix. * @param prefix Prefix to add to the ID. * @param randomize Add a randomized infix string.

(prefix: string, randomize: boolean = false)

Source from the content-addressed store, hash-verified

29 * @param randomize Add a randomized infix string.
30 */
31 getId(prefix: string, randomize: boolean = false): string {
32 // Omit the app ID if it's the default `ng`. Since the vast majority of pages have one
33 // Angular app on them, we can reduce the amount of breakages by not adding it.
34 if (this._appId !== 'ng') {
35 prefix += this._appId;
36 }
37
38 let count = counters.get(prefix);
39
40 if (count === undefined) {
41 count = 0;
42 } else {
43 count++;
44 }
45
46 counters.set(prefix, count);
47 return `${prefix}${randomize ? _IdGenerator._infix + '-' : ''}${count}`;
48 }
49}

Callers 15

column-resize.tsFile · 0.45
ToolbarWidgetClass · 0.45
AccordionTriggerClass · 0.45
AccordionPanelClass · 0.45
GridCellClass · 0.45
GridCellWidgetClass · 0.45
MenuItemClass · 0.45
MenuClass · 0.45
OptionClass · 0.45
ListboxClass · 0.45
TabPanelClass · 0.45

Calls 2

setMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected