]>
Commit | Line | Data |
---|---|---|
8ee25e17 C |
1 | import { Component, ElementRef, Input, OnChanges, ViewChild } from '@angular/core' |
2 | import { CustomMarkupService } from './custom-markup.service' | |
3 | ||
4 | @Component({ | |
5 | selector: 'my-custom-markup-container', | |
24893b52 | 6 | templateUrl: './custom-markup-container.component.html' |
8ee25e17 C |
7 | }) |
8 | export class CustomMarkupContainerComponent implements OnChanges { | |
9 | @ViewChild('contentWrapper') contentWrapper: ElementRef<HTMLInputElement> | |
10 | ||
11 | @Input() content: string | |
12 | ||
13 | constructor ( | |
14 | private customMarkupService: CustomMarkupService | |
15 | ) { } | |
16 | ||
17 | async ngOnChanges () { | |
18 | await this.buildElement() | |
19 | } | |
20 | ||
21 | private async buildElement () { | |
22 | const element = await this.customMarkupService.buildElement(this.content) | |
23 | this.contentWrapper.nativeElement.appendChild(element) | |
24 | } | |
25 | ||
26 | } |