我正在开发一个Angular2应用程序,我需要显示一个<a>
HTML元素.正确的方法是什么?
Updated
请注意*ngFor
,这将阻止使用*ngIf
而不完全呈现<a>
的选项.
<a *ngFor="let link of links"
href="#"
[class.disabled]="isDisabled(link)"
(click)="onClick(link)">
{{ link.name }}
</a>
TypeScript组件的方法如下所示:
onClick(link: LinkObj) {
// Do something relevant with the object...
return false;
}
我需要防止这个元素被点击,而不仅仅是让它看起来像是CSS.我假设一开始可能需要绑定到[disabled]
属性,但这是错误的,因为锚元素没有disabled
属性.
我看过并考虑过使用pointer-events: none
,但这阻止了我cursor: not-allowed
的风格发挥作用——这是要求的一部分.