Home > Software engineering >  How to add picture to tooltip PrimeNG
How to add picture to tooltip PrimeNG

Time:11-30

<i [pTooltip]="picture" tooltipPosition="bottom" ></i> <ng-template #picture> <img src="" alt="here img"> </ng-template>

Error Type 'TemplateRef' is not assignable to type 'string'

Is there a way to add a picture

CodePudding user response:

Seems this is a discussed topic on GitHub. So at least currently template is not supported for tooltip. But I found this comment: which says:

Set escape to false, and it will render html:

<div pTooltip="Some text <br> next line" tooltipPosition="top" [escape]="false"></div>

This seems to work fine with this sample I tried:

<p pTooltip="<img src='http://placekitten.com/g/100/200' />" [escape]="false">Hover me!</p>

DEMO STACKBLITZ

  • Related