简体   繁体   English

如果以角度禁用按钮,则禁用工具提示文本

[英]Disable tooltip text if button is disabled in angular

I'm new to UI, I have requirement for my angular application, where my button will be enabled and disabled on some conditions.我是 UI 的新手,我对我的 angular 应用程序有要求,我的按钮将在某些条件下启用和禁用。 I want to show tooltip only if button is enabled, I'm able to change cursor type on enable/disabled button, but want to know how can I enable the tooltip text only if my button is enabled, below is my code.我只想在启用按钮时显示工具提示,我可以更改启用/禁用按钮上的光标类型,但想知道如何仅在启用按钮时启用工具提示文本,下面是我的代码。

<button ejs-button type="button" (click)="formulabuilder(data) [attr.disabled]="data.disable==true?'':null"  
        title="Formula Builder" class="formula_builder_btn">
    <mat-icon role="img" class="mat-icon material-icons mat-icon-no-color"> apps</mat-icon>
</button>

.formula_builder_btn:disabled {
  cursor: default;
}

.formula_builder_btn{
  cursor: pointer;
}

Is am I doing anything wrong?我做错了什么吗? how can I achieve this.我怎样才能做到这一点。

您可以有条件地添加标题

<button ejs-button type="button" title="{{ data.disable? '' : 'Formula Builder'}}">

We have checked your reported requirement, we can achieve your requirement using CSS styles.我们已经检查了您报告的要求,我们可以使用 CSS 样式来实现您的要求。 We have set the pointer event as none for the disabled element (button) through CSS.我们已经通过 CSS 将禁用元素(按钮)的指针事件设置为无。 Please refer to code snippets.请参考代码片段。

<button ejs-button [isPrimary]="true" [disabled]="true" title="Formula Builder">Primary <button ejs-button [isPrimary]="true" [disabled]="true" title="Formula Builder">主要

.e-btn:disabled { pointer-events: none; .e-btn:disabled { 指针事件:无; } }

For your reference, we have prepared a sample based on this, please refer to below link.我们在此基础上准备了一个样本供您参考,请参考以下链接。

Link: https://stackblitz.com/edit/angular-zcgd11-qjzzns?file=app.component.css链接: https : //stackblitz.com/edit/angular-zcgd11-qjzzns?file=app.component.css

Please let us know if you need any further assistance.如果您需要任何进一步的帮助,请告诉我们。

Regards, Mohan kumar R问候, Mohan kumar R

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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