Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

angularjs Both outer and inner divs have ng-click and when I click on the inner div, both ng-clicks execute. How to prevent that

angular.module('myApp', [])
  .controller('myCtrl', ['$scope', function($scope) {
    $scope.showMoreHandler = function(e) {
      console.log('showMoreHandler');
    }
    $scope.actionHandler = function(e) {
      e.stopPropagation();
      console.log('actionHandler');
    }

  }]);
div {
  padding: 20px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.7.5/angular.min.js"></script>
<div ng-app="myApp" ng-controller="myCtrl">
  <div ng-click="showMoreHandler($event)">showMoreHandler
    <div ng-click="actionHandler($event)">actionHandler</div>
  </div>
</div>
 
PREVIOUS NEXT
Tagged: #angularjs #Both #outer #divs #I #click #How #prevent
ADD COMMENT
Topic
Name
2+5 =