I'm trying to make a card that is all clickable (the class=box) Except for one section that contains buttons which each links to different links that its parent anchor..
我正在尝试制作一张可点击的卡片(class = box)除了一个包含按钮的部分,每个按钮链接到其父锚点的不同链接。
I don't find a way to have one link for the card and a different for a section inside.
我找不到一种方法可以为卡片添加一个链接,而为内部的某个部分添加不同的链接。
<a class="box" href="box-link.html">
<div class="box-text">
<span>Some Text here</span>
<div style="float:right; " ng-click="dosomeotherstuff()">
<span class="glyphicon glyphicon-trash"></span>
</div>
<div style="float:right; " ng-click="somethignelse()">
<span class="glyphicon glyphicon-share"></span>
</div>
</div>
</a>
I'm using Angular, hence the ng-clicks.
我正在使用Angular,因此使用了ng-clicks。
Any ideas on how to sort this out?
关于如何解决这个问题的任何想法?
Adding a fiddle example: http://jsfiddle.net/pepepapa82/svwLh6w1/
添加一个小提琴示例:http://jsfiddle.net/pepepapa82/svwLh6w1/
1 个解决方案
#1
1
You can add more than one action to an ng-click
. In this case, you might want to first prevent the click
event propogating, then trigger your sub-action:
您可以为ng-click添加多个操作。在这种情况下,您可能希望首先阻止click事件传播,然后触发您的子操作:
<a class="box" href="box-link.html">
<div class="box-text">
<span>Some Text here</span>
<div style="float:right; " ng-click="$event.stopPropagation(); dosomeotherstuff()">
<span class="glyphicon glyphicon-trash"></span>
</div>
<div style="float:right; " ng-click="$event.stopPropagation(); somethignelse()">
<span class="glyphicon glyphicon-share"></span>
</div>
</div>
</a>
As an alternative, you could pass $event
as the first argument of your functions, and stop propogation there. This is, IMHO, cleaner.
作为替代方案,您可以将$ event作为函数的第一个参数传递,并在那里停止传播。这是,恕我直言,更清洁。
#1
1
You can add more than one action to an ng-click
. In this case, you might want to first prevent the click
event propogating, then trigger your sub-action:
您可以为ng-click添加多个操作。在这种情况下,您可能希望首先阻止click事件传播,然后触发您的子操作:
<a class="box" href="box-link.html">
<div class="box-text">
<span>Some Text here</span>
<div style="float:right; " ng-click="$event.stopPropagation(); dosomeotherstuff()">
<span class="glyphicon glyphicon-trash"></span>
</div>
<div style="float:right; " ng-click="$event.stopPropagation(); somethignelse()">
<span class="glyphicon glyphicon-share"></span>
</div>
</div>
</a>
As an alternative, you could pass $event
as the first argument of your functions, and stop propogation there. This is, IMHO, cleaner.
作为替代方案,您可以将$ event作为函数的第一个参数传递,并在那里停止传播。这是,恕我直言,更清洁。