import { Component , ElementRef , Input , Inject , ChangeDetectorRef , OnChanges , SimpleChanges , } from '@angular/core' ; import { Icons } from './icons.provider' ; import { uppercamelcase } from './utils' ; @ Component ( { selector : 'i-feather, feather-icon' , templateUrl : './feather.component.html' , styleUrls : [ './feather.component.scss' ] , } ) export class FeatherComponent implements OnChanges { @ Input ( ) name ! : string ; constructor ( @ Inject ( ElementRef ) private elem , @ Inject ( ChangeDetectorRef ) private changeDetector , @ Inject ( Icons ) private icons ) { } ngOnChanges ( changes ) { const icons = Object . assign ( { } , ... ( this . icons as any as object [ ] ) ) ; const svg = icons [ uppercamelcase ( changes . name . currentValue ) ] || '' ; if ( ! svg ) { console . warn ( `Icon not found: ${ changes . name . currentValue }\n` + `Refer to documentation on https://github.com/michaelbazos/angular-feather` ) ; } this . elem . nativeElement . innerHTML = svg ; this . changeDetector . markForCheck ( ) ; } }