angular 阻止冒泡

来源:互联网 发布:java简易订餐系统 编辑:程序博客网 时间:2024/06/06 21:44

方法一

<i class="fa fa-times icon-muted  fa-fw ss-select-item-close" ng-click="del();$event.stopPropagation();"  title="删除该选项"></i>//当 del方法是由父 controller 定义的  这种方法就很好用了。

方法二

//html code:<i class="fa fa-times icon-muted  fa-fw ss-select-item-close" ng-click="del($event);$event.stopPropagation();"  title="删除该选项"></i>//js code:scope.del = function($event){    $event.stopPropagation();}


$event.stopPropagation();:可以写在方法里面,也可以写在 ng-click里面;ng-click里面可以写js代码