Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have HTML structure with ng-click:

<div ng-click="parent()">
  <div ng-click="d"></div>
</div>

How I can disable outside ng-click="parent()" if I do ng-click="d"

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
893 views
Welcome To Ask or Share your Answers For Others

1 Answer

Use the stopPropagation method on the angular $event object:

<div ng-click="parent()">
  <div ng-click="d(); $event.stopPropagation();"></div>
</div>

Or pass the $event object as an argument of the ng-click method, and call stopPropagation in the method:

<div ng-click="parent()">
  <div ng-click="d($event)"></div>
</div>

In d:

$scope.d = function (event) {
    // ...
    event.stopPropagation();
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...