Posts

Showing posts with the label angular2-template

Angular2, what is the correct way to disable an anchor element?

Angular2, what is the correct way to disable an anchor element? I'm working on an Angular2 application, and I need to display -- but disable an <a> HTML element. What is the correct way to do this? disable <a> Updated Please note the *ngFor , this would prevent the option of using *ngIf and not rendering the <a> altogether. *ngFor *ngIf <a> <a *ngFor="let link of links" href="#" [class.disabled]="isDisabled(link)" (click)="onClick(link)"> {{ link.name }} </a> The TypeScript component has a method that looks like this: onClick(link: LinkObj) { // Do something relevant with the object... return false; } I need to actually prevent the element from being clickable, not just appear that it is with the CSS . I was assuming that I needed to potentially bind to the [disabled] attribute at first, but this is incorrect as the anchor element doesn't have a disabled property. [disabled]...