Ziad Ziad - 4 years ago 275
HTML Question

ui-sref - new tab without <a> tag

I can open a link in a new tab with ui-sref in an a tag :

<a ui-sref="my-state"></a>

Now, I want to be able to open a link in a new tab, inside an a tag :

<a ui-sref="my-first-state">
<a ui-sref="my-second-state" ng-click="$event.stopPropagation();"></a>

The problem is that we can't have an a tag inside another one (Is it ok to have an `<a>` inside another `<a>`?).

How can I achieve this (knowing that opening a new tab with ui-sref is not possible with another tag than a) ?


Answer Source

Use button and ngClick directive to provide clear and valid html and js code

To have opportunity of opening in new tab pass event in functions and then check for ctrl modifier

  if (e.ctrlKey || e.metaKey){//ctrlKey - Windows, metaKey - OSX
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download