templateUrl: './custom-markup-container.component.html'
})
export class CustomMarkupContainerComponent implements OnChanges {
- @ViewChild('contentWrapper') contentWrapper: ElementRef<HTMLInputElement>
+ @ViewChild('contentWrapper', { static: true }) contentWrapper: ElementRef<HTMLInputElement>
- @Input() content: string
+ @Input() content: string | HTMLDivElement
displayed = false
) { }
async ngOnChanges () {
- await this.buildElement()
+ await this.rebuild()
}
- private async buildElement () {
- if (!this.content) return
+ private async rebuild () {
+ if (this.content instanceof HTMLDivElement) {
+ return this.loadElement(this.content)
+ }
const { rootElement, componentsLoaded } = await this.customMarkupService.buildElement(this.content)
- this.contentWrapper.nativeElement.appendChild(rootElement)
-
await componentsLoaded
+ return this.loadElement(rootElement)
+ }
+
+ private loadElement (el: HTMLDivElement) {
+ this.contentWrapper.nativeElement.appendChild(el)
+
this.displayed = true
}
}