[英]Call an Angular $scope.Function from href in current or new tab by right click?
I have following HTML: 我有以下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".
仅在单击“在新选项卡中打开”时,才需要执行redirectToEntity函数。
In order to let the normal right-click menu work, the <a>
needs to be a regular anchor tag. 为了使正常的右键单击菜单起作用,
<a>
必须是常规的定位标记。 So it can't be activated by ng-click
. 因此,无法通过
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}}">
. 如果
redirectToEntity()
所做的只是生成一个URL并从控制器内部进行重定向,则也许您应该只生成该URL并将其添加到href中,例如<a href="{{linkGeneratedInController}}">
。
Alternatively, you can also use a directive to bind an action to the right click, as is shown here . 或者,您也可以使用指令将操作绑定到右键单击, 如此处所示 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.