I am creating an Angular application in which I don't have to use the HTML file means I cannot edit the HTML file (for purpose) manually. In the below Pseudo code, I am using the setAttribute() method to set the id attribute to the div I click on -
constructor(
private renderer: Renderer2
) {
this.renderer.listen(document.body, 'click', (event) => {
this.elementHandler(event.srcElement);
});
}
elementHandler(element: any) {
if (!element?.id) {
element.setAttribute('id', 'someId');
}
}
Now, all I want is to append an Angular component inside that specific div with the Id that I had set using elementHandler Method as shown in the above code.
Note - The Angular component I want to append is imported from the library - @kolkov/angular-editor( https://www.npmjs.com/package/@kolkov/angular-editor ) and the component I want to append to the HTML file -
<angular-editor [(ngModel)]="htmlContent" [config]="config"></angular-editor>
How I can achieve it ?
Would be very grateful for your help.