首页 > anguar 事件冒泡怎么处理,我想change的时候只弹33,divclick的时候 只弹2

anguar 事件冒泡怎么处理,我想change的时候只弹33,divclick的时候 只弹2

<!DOCTYPE html>
<html lang="en" ng-app="app">
<head>

<meta charset="UTF-8">
<title>Title</title>
<style>
 
    div{
        width: 200px;
        height: 200px;
        border:1px solid red;
        float: left;
    }
</style>
<script src="angular.min.js"></script>

<script>
    var App=angular.module('app',[])
    App.controller('a',function($scope){
        $scope.b=[{id:"0",name:'全部通讯'},{id:"1",name:'通讯1'},{id:"2",name:'通讯2'},{id:"3",name:'通讯3'}];
        $scope.show=function(){
            alert(2);
        }
        $scope.change=function(){
            alert(33);
        }
        $scope.a=$scope.b[0].id;
    })
</script>

</head>
<body ng-controller="a">

  <div ng-click="show()">
      <select ng-model="a" ng-options="a.id as a.name for a in b" ng-change="change();$event.stopPropagation();"></select>
  </div>

</body>
</html>


ng-click="clickSelect($event);"

$scope.clickSelect = function($event) {
    $event.stopPropagation();
    …
}
【热门文章】
【热门文章】