I should show a tooltip when I hover an svg element.
I would like that the tooltip is an angular component for easier UI creating.
the constraint is that the svg element is created programmatically so I don't know how to create the template referencer for dynamic component rendering.
My question is how can I build an angular component as a tooltip of a dynamic svg element ?
Here's a sample on stackblitz. I wrote the code of the dynamic component. now I should render it dynamically when hovering the circle.
@ViewChild('cont', { static:true,read: ViewContainerRef }) entry: ViewContainerRef;
constructor(private resolver: ComponentFactoryResolver) { }
@ViewChild('svg', { static: true }) svg: ElementRef
ngAfterViewInit() {
let circle= document.createElementNS('http://www.w3.org/2000/svg','circle')
circle.setAttribute('r','40');
circle.setAttribute('cx','50');
circle.setAttribute('cy','50');
//let cont= document.createAttributeNS('http://www.w3.org/2000/svg','#cont')
//circle.setAttribute('#cont','test')
this.svg.nativeElement.appendChild(circle)
this.entry.clear();
const factory = this.resolver.resolveComponentFactory(TooltipComponent);
const componentRef = this.entry.createComponent(factory);
}