import { Component, Optional, Input, Injector } from '@angular/core';

@Component({
  selector: 'ng-svg-icon',
  exportAs: 'ngSvgIcon',
  templateUrl: './ng-svg-icon.component.pug',
  styleUrls: []
})
export class NgSvgIconComponent {
  @Input() file: string = null;
  @Input() name: string = null;

  get url(): string {
    if (this.file && this.name) {
      return `${this.file}#${this.name}`;
    } else if (this.file) {
      return `${this.file}`;
    }
    return '#';
  }

  constructor(@Optional() private context: Injector) {
  }
}
