Thursday, 11 March 2021

Angular 8 how to bind event to anchor tag && JS anchor with no effect

 <a [routerLink]="" (click)="onGoToPage2()">Go to page</a>

https://stackoverflow.com/questions/41458842/attaching-click-to-anchor-tag-in-angular


--------------------------------------------------------------------------------------------------------------------------------------

https://stackoverflow.com/questions/134845/which-href-value-should-i-use-for-javascript-links-or-javascriptvoid0
https://stackoverflow.com/questions/1291942/what-does-javascriptvoid0-mean#:~:text=Usage%20of%20javascript%3Avoid(0,prevent%20the%20page%20from%20refreshing.

href="#" will route to # if using front end framework
 <a href="javascript:void(0)" onclick="myJsFunc();">Run JavaScript Code</a>

void is an operator that is used to return a undefined value so the browser will not be able to load a new page.

No comments:

Post a Comment