Task - Create a reusable button/anchor tag attribute selected component for an Angular library, with as much of the logic for the behavior tied up in the component itself not on the HTML markup.
HTML markup should be as clean as possible ideally
<a routerLink="" attributeSelectorForComponent></a>
Issue - Trying to prevent routerLink from firing when [attr.disabled]
is present on the anchor tag, with a click listener.
@HostListener('click', ['$event']) onMouseClick(event: Event) {
event.stopImmediatePropagation();
event.preventDefault()
}
Removed the disabled logic from the equation for simplicity, routerLink is still fired regardless.
Proposed solutions - How can I conditionally disable the routerLink attribute? Doesn't really help address my issue, disabling pointer-events will only disable mouse events not keyboard events, and also prevents me from being able to remove the pointer-events: none with a mouseover, click ect requiring what would be a relatively convoluted solution to detect the disable attribute and remove the css accordingly, and in general seems like more a hacky solution than a correct one.