如何在不单击div的情况下单击可点击div(ng-click)内的标签?

时间:2022-08-25 23:32:18

Here is the code:

这是代码:

<div ng-click="grid.appScope.navToPage(row)"class="ui-grid-cell" ui-grid-cell style="cursor: pointer">
   <div class="ui-grid-cell-contents">
     <a ng-href="/mywebpage/2" target="_blank">
       <span class="glyphicon glyphicon-new-window"></span>
     </a>
   </div>'
</div>

I want to figure out some way to be able to click the a tag link without clicking the div with the ng-click. Is there a good way to do this?

我想找出一些方法可以点击标签链接而不用ng-click单击div。有没有一个很好的方法来做到这一点?

2 个解决方案

#1


4  

You can prevent click propagation using the $event.stopPropagation() which is available on many angular directives such as ng-click. Please have a look at this question AngularJS ng-click stopPropagation

您可以使用$ event.stopPropagation()来阻止点击传播,该事件可用于许多角度指令,例如ng-click。请看一下这个问题AngularJS ng-click stopPropagation

In your case, the anchor tag should look like this:

在您的情况下,锚标记应如下所示:

<a ng-href="/mywebpage/2" ng-click="$event.stopPropagation()" target="_blank">
   <span class="glyphicon glyphicon-new-window"></span>
</a>     

#2


1  

Try this

尝试这个

<a ng-href="/mywebpage/2" target="_blank" ng-click="$event.stopPropagation()"><span class="glyphicon glyphicon-new-window"></span></a>

#1


4  

You can prevent click propagation using the $event.stopPropagation() which is available on many angular directives such as ng-click. Please have a look at this question AngularJS ng-click stopPropagation

您可以使用$ event.stopPropagation()来阻止点击传播,该事件可用于许多角度指令,例如ng-click。请看一下这个问题AngularJS ng-click stopPropagation

In your case, the anchor tag should look like this:

在您的情况下,锚标记应如下所示:

<a ng-href="/mywebpage/2" ng-click="$event.stopPropagation()" target="_blank">
   <span class="glyphicon glyphicon-new-window"></span>
</a>     

#2


1  

Try this

尝试这个

<a ng-href="/mywebpage/2" target="_blank" ng-click="$event.stopPropagation()"><span class="glyphicon glyphicon-new-window"></span></a>