简体   繁体   中英

How to attach NGBootstrap tooltip to font awesome icon

Trying to add a tooltip to a font awesome icon in an Angular page. The normal Bootstrap method seems to be ignored so I am trying to use the NGBootstrap method used for adding a tooltip to buttons, but the tool tip never displays. https://ng-bootstrap.github.io/#/components/tooltip/examples

The typical Bootstrap method causes an error of Cannot set property 'title' of undefined when hovering.

<i class="fa fa-info-circle" data-toggle="tooltip" title="Name here"></i>

In the component:

ngafterviewinit() {
    $(function() {
        $('[data-toggle="tooltip"]').tooltip();
    }
};

这似乎可行:

<i id="icon" class="fa fa-1x fa-info-circle" [ngClass]="icon" aria-hidden="true" placement="right" ngbTooltip="tipContent"></i>

You can also try using button tag.

<div class="infoCSSClass">
    <button class="icon-info" data-container="body" ngbTooltip="Here is tooltip text"  #toolTip="ngbTooltip"  (click)="toolTip.open()" placement="top"></button>
</div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM