I am trying to attach the element to parent DOM onClick. how to call the component dynamically? If I add simple " hello world , it works as expected. but I want to call the "myCustomTag" component.
Note: If I add "myCustomTag tag" directly in the template, it works. It is attaching the "myCustomTag" template as expected.
@Component({
selector: 'myTag',
template: `<div (click) = "onAttachClick()"> clickToAddELement </div>`
})
export class xxx {
getNewElement() {
return '<myCustomTag [name]="someText"></myCustomTag>'
}
//on click, I need to add the element
onAttachClick() {
this.parentElement.insertAdjacentHTML('beforeend',this.getNewElement());
}
}