]>
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', | |
f7894f09 C |
6 | templateUrl: './custom-markup-container.component.html', |
7 | styleUrls: [ './custom-markup-container.component.scss' ] | |
8ee25e17 C |
8 | }) |
9 | export class CustomMarkupContainerComponent implements OnChanges { | |
10 | @ViewChild('contentWrapper') contentWrapper: ElementRef<HTMLInputElement> | |
11 | ||
12 | @Input() content: string | |
13 | ||
14 | constructor ( | |
15 | private customMarkupService: CustomMarkupService | |
16 | ) { } | |
17 | ||
18 | async ngOnChanges () { | |
19 | await this.buildElement() | |
20 | } | |
21 | ||
22 | private async buildElement () { | |
23 | const element = await this.customMarkupService.buildElement(this.content) | |
24 | this.contentWrapper.nativeElement.appendChild(element) | |
25 | } | |
26 | ||
27 | } |