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

Method _splitIconName

src/material/icon/icon.ts:274–287  ·  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

272 * 'a:b:c' -> (throws Error)`
273 */
274 private _splitIconName(iconName: string): [string, string] {
275 if (!iconName) {
276 return ['', ''];
277 }
278 const parts = iconName.split(':');
279 switch (parts.length) {
280 case 1:
281 return ['', parts[0]]; // Use default namespace.
282 case 2:
283 return <[string, string]>parts;
284 default:
285 throw Error(`Invalid icon name: "${iconName}"`); // TODO: add an ngDevMode check
286 }
287 }
288
289 ngOnInit() {
290 // 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