angularJs-- stop event bubbling

Reference:  https://blog.csdn.net/github_38469481/article/details/72758385

 

My needs: accordion fold list, click a row to open the fold, but there is an element b ng-click events change on the line (). Click a row triggers unfolded + change () event.

The reason: b click event change () bubbling to the parent element a.

Solution: by $ event.stopPropagation () to stop the event from bubbling.

  Methods In one: the elements on an additional

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

 

  Method two: the incident in an additional  

  <div ng-click="change($event)">111</div>
  $scope.change(e){
    ***
    e.stopPropagation();
  }

 

Guess you like

Origin www.cnblogs.com/linjiangxian/p/12503831.html