import { Component , Input , ChangeDetectionStrategy , ElementRef , Renderer2 , Inject , Optional } from '@angular/core' ; import { normalizeIconName } from './util' ; import { NglIconConfig , NGL_ICON_CONFIG } from './config' ; @ Component ( { selector : 'svg[nglIconName]' , templateUrl : './svg.html' , changeDetection : ChangeDetectionStrategy . OnPush , } ) export class NglIconSvg { path : string ; @ Input ( 'nglIconName' ) set iconName ( iconName ) { const [ category , icon ] = normalizeIconName ( iconName ) . split ( ':' ) ; this . iconPath = `${ this . path }/${ category }-sprite/svg/symbols.svg#${ icon }` ; } @ Input ( ) xPos = '0' ; iconPath : string ; constructor ( @ Optional ( ) @ Inject ( NGL_ICON_CONFIG ) defaultConfig , el , renderer ) { renderer . setAttribute ( el . nativeElement , 'aria-hidden' , 'true' ) ; const config = { ... new NglIconConfig ( ) , ... defaultConfig } ; this . path = config . svgPath ; } }