Monday, July 17, 2017

a hack to make a (click) event behave like a hyperlink in the Angular 2 space

An a tag like this with both a href setting and a click event can behave well without any help from CSS styling.

<a href="#" (click)="doWhatever()">touch me</a>

 
 

You will need to make the click event itself return false so that the tag does not actually redirect away anywhere when clicked.

doWhatever():boolean{
   alert('whatever');
   return false;
}

No comments:

Post a Comment