My answer might be late for this post. It can be achieved through inline css within anchor tag only.
<a [routerLink]="['/user']" [style.pointer-events]="isDisabled ?'none':'auto'">click-label</a>
Considering isDisabled
is a property in component which can be true
or false
.
Plunker for it: https://embed.plnkr.co/TOh8LM/
.disabled{ pointer-events: none }
will disable the click event, but not the tab event. To disable the tab event, you can set the tabindex to -1 if the disable flag is true.
<li [routerLinkActive]="['active']" [class.disabled]="isDisabled">
<a [routerLink]="['link']" tabindex="{{isDisabled?-1:0}}" > Menu Item</a>
</li>
I have used
tabindex="{{isEditedParaOrder?-1:0}}"
[style.pointer-events]="isEditedParaOrder ?'none':'auto'"
in my anchor tag so that they can not move to anchor tag by using tab to use "enter" key and also pointer itself we are setting to 'none' based on property 'isEditedParaO rder' whi
You can try this
<a [attr.disabled]="someCondition ? true: null"></a>