ng-click
and ng-href
directives when used together will first execute click function. In the following example navigation to Google will be prevented and alert will be shown.
<a ng-href='http://google.com' ng-click="click($event)">Link</a>
$scope.click = function (event) {
event.preventDefault();
alert('click has been trigerred');
}
This will work though only when user clicks a link using left mouse button. If user will try to open the link in a new tab the click event won't be triggered. To some extent it seems correct because it's not strictly speaking "click", but is there any Angular directive for handling opening link in the new tab?
UPDATE:
I don't want to open new tab programatically, but handle event of opening new tab by the user.