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

Method _splitIconName

src/material/icon/icon.ts:276–289  ·  view source on GitHub ↗

* Splits an svgIcon binding value into its icon set and icon name components. * Returns a 2-element array of [(icon set), (icon name)]. * The separator for the two fields is ':'. If there is no separator, an empty * string is returned for the icon set and the entire value is returned for

(iconName: string)

Source from the content-addressed store, hash-verified

274 * 'a:b:c' -> (throws Error)`
275 */
276 private _splitIconName(iconName: string): [string, string] {
277 if (!iconName) {
278 return ['', ''];
279 }
280 const parts = iconName.split(':');
281 switch (parts.length) {
282 case 1:
283 return ['', parts[0]]; // Use default namespace.
284 case 2:
285 return <[string, string]>parts;
286 default:
287 throw Error(`Invalid icon name: "${iconName}"`); // TODO: add an ngDevMode check
288 }
289 }
290
291 ngOnInit() {
292 // Update font classes because ngOnChanges won't be called if none of the inputs are present,

Callers 1

_updateSvgIconMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected