angular 阻止冒泡

版权声明:转载的时候提到我就行…… https://blog.csdn.net/SakuraLLj/article/details/72900397

方法一

<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代码

猜你喜欢

转载自blog.csdn.net/SakuraLLj/article/details/72900397