[attr.disabled] ="真"不适用于锚标签

时间:2017-05-29 10:53:26

标签: angular typescript attributes anchor

为什么[attr.disabled]="true"无法在锚标记中工作?

成分:

this.isHold=true;

HTML:

<a (click)="showDialogToHold()" href="Javascript:void(0);" class="a-l2-link 
img-space" icon="fa-angle-right" [attr.disabled]="isHold">Hold</a>

我也试过[disabled]="isHold"。但[disabled]不支持锚标记。它会抛出与Can't bind to 'disabled' since it isn't a known property of 'li'

相关的错误Can't bind to 'disabled' since it isn't a known property of 'a'

3 个答案:

答案 0 :(得分:0)

html中的超链接没有禁用属性。参考https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a。因此,您可以使用css来实现此目的。

CSS代码:

text-decoration:none;
cursor:default;
color:grey;
poniter-events:none;

答案 1 :(得分:0)

尝试:

package Q44240531_TestNG_Main;

import org.testng.annotations.Test;

public class TESTClass extends TESTTNGClass {

          @Test
          public void f() 
          {
              System.out.println("In Test");
          }
}

答案 2 :(得分:0)

   .disabled {
           pointer-events: none !important;
           cursor: default;
    }
<a (click)="showDialogToHold()" href="Javascript:void(0);" class="a-l2-link 
img-space" icon="fa-angle-right" [ngStyle]="{ 'disabled ': isHold }">Hold</a>