0

I have following HTML:

<a href="" ng-click='redirectToEntity("B-",obj.id")'>Click me and Process function and then redirect</a>

This code does process function and redirect to page which I am targeting, but this does not work for Open in new tab by right clicking. I've tried numerous solution but none worked for me. I need to execute redirectToEntity function only when clicked on "Open in New Tab".

LadyCode
  • 1
  • 2

1 Answers1

1

In order to let the normal right-click menu work, the <a> needs to be a regular anchor tag. So it can't be activated by ng-click. If all that redirectToEntity() does is generate a url and redirect from within the controller, maybe instead you should just generate the url and add it to the href like this <a href="{{linkGeneratedInController}}">.

Alternatively, you can also use a directive to bind an action to the right click, as is shown here.

Community
  • 1
  • 1
Yaakov Ellis
  • 40,752
  • 27
  • 129
  • 174