How to add conditional tooltip using primeng?

Viewed 13512

I am trying to add a conditional tooltip over a button. Using primeng tooltip component:

<div pTooltip="Please upload" style="display:inline-block;" tooltipPosition="top" 
   tooltipDisabled = "flag">
     <button class="btn btn-primary btn-xs"><i class="fa fa-check" 
     aria-hidden="true"></i></button>
</div>

It is not working.

However, tooltip without "tooltipDisabled" is working fine.

Can someone please help me?

3 Answers

I know this thread is old but maybe help others like helped to me. The listed solutions did not solve my problem but give me an idea: Only when i put [pTooltip]="variableWithMyText" with brackets and bind into a local variable with text content and combined with [tooltipDisabled]="flag", my code worked perfectly.

HTML (Condensed to minimum attributes for explanation):

<div [pTooltip]="tooltipText" [tooltipDisabled]="hideTooltip"></div>

Typescriptp file (Condensed to minimum attributes for explanation):

hideTooltip: boolean;
tooltipText = 'This text will showed on Tooltip';

if(conditionToShowTooltip){
    this.hideTooltip = true;
} else {
    this.hideTooltip = false;
}
Related