angularjs 1.x 阻止事件冒泡

前端之家收集整理的这篇文章主要介绍了angularjs 1.x 阻止事件冒泡前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
<!DOCTYPE html>
<html>
<head>
<Meta charset="utf-8">
<script src="http://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.js"></script>
</head>
<body>

<div ng-app="myApp" ng-controller="myCtrl">
	<div ng-click='del($event);'>
		<button ng-click="add($event);">点我!</button>

		<p>{{ count }}</p>
	</div>
</div>
<script>
var app = angular.module('myApp',[]);
app.controller('myCtrl',function($scope) {
    $scope.count = 0;
	$scope.add=function($event){
		
		$event.stopPropagation();
		$scope.count = $scope.count + 1;
	};
	$scope.del = function($event){
		$scope.count = $scope.count - 1;
	};
});
	
</script>

</body>
</html>

猜你在找的Angularjs相关文章