Skip to content

Instantly share code, notes, and snippets.

@NetanelBasal
Last active December 17, 2020 16:52
Show Gist options
  • Select an option

  • Save NetanelBasal/5e9ac215990665b700f31bdf08e3abdb to your computer and use it in GitHub Desktop.

Select an option

Save NetanelBasal/5e9ac215990665b700f31bdf08e3abdb to your computer and use it in GitHub Desktop.
@Directive({
selector: '[tooltip]'
})
class TooltipDirective {
@Input() tooltip;
private _tooltipEle;
constructor(private el: ElementRef) {}
ngAfterContentInit() {
this._tooltipEle = $(`<div class="tooltip">${this.tooltip}<div class="tooltip-arrow"></div></div>`).appendTo( "body" );
this._createTooltip();
}
@HostListener("mouseover")
showTooltip() {
this.toggleTooltip();
}
@HostListener("mouseout")
removeTooltip() {
this.toggleTooltip();
}
private _createTooltip() {
// create tooltip...
}
toggleTooltip() {
this._tooltipEle.toggleClass("tooltip-show")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment