Wednesday, May 24, 2017

Keep an a tag from redirecting in Angular 2.

<a href="#" (click)="go($event); false">whatever</a>

This can be advantageous. This in lieu of not having the href parameter and forcing the a tag to behave as if the href were there with a different styling that does cursor:pointer; and whatever else you need to hack a sick a tag into behaving as if unsick. What is more ghetto?

 
 

Addendum 6/21/2019: You could also just have the "go" method return false. This will let you skip the trailing false inline in the HTML tag.

No comments:

Post a Comment