Published on

Adding (click) on anchor tag instead link in Angular

If you want to invoke some function on a user click you should first look for Buttons, But for what ever the reason (some times for styling) if you want to use an anchor tag you may want to stop the default behaviour of anchor tag. Otherwise If you use # in href it refreshes the current page and if you put nothing it takes you to home. The following code shows you how to stop the default behaviour and calls the function.

<a ng-click="$event.preventDefault(); your_function()" href />