Search code examples
htmlangularjsangularjs-ng-click

How to allow 'Open in a new tab' when using ng-click?


I have a table on HTML and each row leads to a different page, with more details about that row. But as I am using angularjs, with ng-click I can't right click this row and select 'open in a new tab'. Is there any way to solve it?

Thanks in advance!


Solution

  • If possible you should convert your element to an anchor element.

    <a ng-href="{{ your dynamic url }}" ng-click="your function">Your link text</a>
    

    The browser will interpret the element as a link, and will therefor give you the correct dropdown. Note that you also have to have the correct href value to open in a new tab.

    EDIT: I would recommend this question if you want a more detailed answer on how to fix this kind of behaviour using JQuery.