1 import { Directive, ElementRef, Input, OnInit, Renderer2 } from '@angular/core'
2 import { PluginSelectorId } from '@shared/models'
4 @Directive({ selector: '[myPluginSelector]' })
5 export class PluginSelectorDirective implements OnInit {
6 @Input() pluginSelectorId: PluginSelectorId
9 private renderer: Renderer2,
10 private hostElement: ElementRef<HTMLElement>
16 const id = this.hostElement.nativeElement.getAttribute('id')
17 if (id) throw new Error('Cannot set id on element that already has an id')
19 this.renderer.setAttribute(this.hostElement.nativeElement, 'id', `plugin-selector-${this.pluginSelectorId}`)