import { Component , OnInit , Input , ViewChildren , TemplateRef , AfterViewInit , ElementRef , HostBinding } from '@angular/core' ; import { BUILTIN_SVGS } from './svgs' ; import { DomSanitizer } from '@angular/platform-browser' ; @ Component ( { selector : 'dg-icon' , templateUrl : './icon.component.html' } ) export class IconComponent implements OnInit , AfterViewInit { @ HostBinding ( 'class.dg-icon' ) isIcon = true ; @ Input ( ) set iconName ( name ) { this . setSvg ( name ) ; } constructor ( private elementRef , private domSanitizer ) { } ngOnInit ( ) { } ngAfterViewInit ( ) { } setSvg ( name ) { const svg = BUILTIN_SVGS [ name ] ; if ( svg ) { this . elementRef . nativeElement . innerHTML = svg ; } else { this . elementRef . nativeElement . innerHTML = '' ; } } }