]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/shared/shared-main/plugins/plugin-selector.directive.ts
Merge branch 'release/4.2.0' into develop
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-main / plugins / plugin-selector.directive.ts
CommitLineData
8afade26
C
1import { Directive, ElementRef, Input, OnInit, Renderer2 } from '@angular/core'
2import { PluginSelectorId } from '@shared/models'
3
4@Directive({ selector: '[myPluginSelector]' })
5export class PluginSelectorDirective implements OnInit {
6 @Input() pluginSelectorId: PluginSelectorId
7
8 constructor (
9 private renderer: Renderer2,
10 private hostElement: ElementRef<HTMLElement>
11 ) {
12
13 }
14
15 ngOnInit () {
16 const id = this.hostElement.nativeElement.getAttribute('id')
17 if (id) throw new Error('Cannot set id on element that already has an id')
18
19 this.renderer.setAttribute(this.hostElement.nativeElement, 'id', `plugin-selector-${this.pluginSelectorId}`)
20 }
21}