I use the tooltip directive, so when I click <button>, I dynamically insert and show the tooltip.
It works well, and I see the prompts:

This is the code I used to enter the tooltip when I clicked the button:
@Directive({ selector: '[popover]'})
class Popover {
private _component: ComponentRef<>;
constructor(private _vcRef: ViewContainerRef, private _cfResolver: ComponentFactoryResolver,private elementRef: ElementRef) {
}
@HostListener('click')
toggle() {
if (!this._component) {
const componentFactory = this._cfResolver.resolveComponentFactory(PopoverWindow);
this._component = this._vcRef.createComponent(componentFactory);
} else {
this._vcRef.clear()
this._component.destroy();
this._component = null;
}
}
}
But I do not want more than one tooltip to appear on the screen.
In other words, before I insert a tooltip - I want to delete all existing tooltips - if any.
Question:
How can I “find” all existing tooltips and delete them before inserting a new one?
I know that I can add a class to each of them and then remove them through removeNode, but I want to do this with Angular.
Plunker
BTW. , . ( ).