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>
</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>`?的新标签页。
我怎样才能做到这一点(知道用 a 打开另一个标签无法打开带有ui-sref的新标签页?)
由于
答案 0 :(得分:1)
使用button
和ngClick
指令提供清晰有效的html和js代码
有机会在新标签中打开函数中的事件传递事件,然后检查ctrl修饰符
e.preventDefault();
if (e.ctrlKey || e.metaKey){//ctrlKey - Windows, metaKey - OSX
window.open('http://someurl.com','_blank')
}