我有HTML结构ng-click:
ng-click
<div ng-click="parent()"> <div ng-click="d"></div> </div>
如何禁用外ng-click="parent()",如果我做ng-click="d"
ng-click="parent()"
ng-click="d"
stopPropagation在角度$event对象上使用该方法:
stopPropagation
$event
<div ng-click="parent()"> <div ng-click="d(); $event.stopPropagation();"></div> </div>
或将$event对象作为ng-click方法的参数传递,然后调用stopPropagation方法:
<div ng-click="parent()"> <div ng-click="d($event)"></div> </div>
在d:
d
$scope.d = function (event) { // ... event.stopPropagation(); }