如何使用 primeng 添加条件工具提示?
How to add conditional tooltip using primeng?
我正在尝试在按钮上添加条件工具提示。使用 primeng 工具提示组件:
<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>
它不起作用。
但是,没有 "tooltipDisabled" 的工具提示工作正常。
有人可以帮助我吗?
改用[tooltipDisabled]="flag"
tooltipDisabled 正在寻找布尔值。
您给它一个字符串(而不是我期望看到代码的组件的 flag
属性)。
改用[tooltipDisabled]="flag"
。
我知道这个话题很旧,但也许可以像帮助我一样帮助其他人。列出的解决方案并没有解决我的问题,但给了我一个想法:只有当我把 [pTooltip]="variableWithMyText"
放在方括号中并绑定到一个带有文本内容的局部变量并与 [tooltipDisabled]="flag"
结合时,我的代码才能完美运行。
HTML(为了解释压缩到最小属性):
<div [pTooltip]="tooltipText" [tooltipDisabled]="hideTooltip"></div>
Typescriptp 文件(为了解释而压缩到最小属性):
hideTooltip: boolean;
tooltipText = 'This text will showed on Tooltip';
if(conditionToShowTooltip){
this.hideTooltip = true;
} else {
this.hideTooltip = false;
}
我正在尝试在按钮上添加条件工具提示。使用 primeng 工具提示组件:
<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>
它不起作用。
但是,没有 "tooltipDisabled" 的工具提示工作正常。
有人可以帮助我吗?
改用[tooltipDisabled]="flag"
tooltipDisabled 正在寻找布尔值。
您给它一个字符串(而不是我期望看到代码的组件的 flag
属性)。
改用[tooltipDisabled]="flag"
。
我知道这个话题很旧,但也许可以像帮助我一样帮助其他人。列出的解决方案并没有解决我的问题,但给了我一个想法:只有当我把 [pTooltip]="variableWithMyText"
放在方括号中并绑定到一个带有文本内容的局部变量并与 [tooltipDisabled]="flag"
结合时,我的代码才能完美运行。
HTML(为了解释压缩到最小属性):
<div [pTooltip]="tooltipText" [tooltipDisabled]="hideTooltip"></div>
Typescriptp 文件(为了解释而压缩到最小属性):
hideTooltip: boolean;
tooltipText = 'This text will showed on Tooltip';
if(conditionToShowTooltip){
this.hideTooltip = true;
} else {
this.hideTooltip = false;
}