Я пытаюсь создать создатель компонента angular и хотел бы иметь возможность динамически генерировать код HTML для этого компонента. Я уже пробовал это, но я не могу найти способ динамической установки типа элемента в коде HTML.
import {Component, Input} from '@angular/core';
export class BaseComponent<K extends HTMLElement> {
public type: K;
public classes: string[] = [];
public style = {};
public childNodes: BaseComponent<HTMLElement>[];
}
@Component({
selector: 'base-component',
template: `
<<my component.type here> [ngClass]="this.component.classes" [ngStyle]="this.component.style" ]>
<base-component *ngFor="let child of component.childNodes" [component]="child"></base-component>
</<my component.type here>>
`
})
export class GraphicalComponent {
@Input()
public component: BaseComponent<HTMLElement>;
}
, но пока я не нашел способа правильно внедрить мой элемент типа k в если я не использую функцию document.createElement, которая на самом деле не имеет смысла в angular справочной программе