stoping propagation of $boradcast
http://angularjs.org/
by Divya Manu
HTML
<script src="http://code.angularjs.org/angular-1.0.1.js"></script>
<div ng-app="myApp" ng-controller="myCtrl">
<a ng-click="click()">broadcast</a>
<div ng-controller="A"></div>
<div ng-controller="B"></div>
<div ng-controller="C"></div>
</div>
JavaScript
var myApp = angular.module('myApp',[]);
myApp.controller('myCtrl', function($scope,$rootScope) {
$scope.$on("test",function(){
alert("myCntrl has recieved it");
});
$scope.click=function(){
$scope.$broadcast("test");
};
});
myApp.controller('A', function($scope) {
$scope.$on("test",function(){
alert("A has recieved it");
});
});
myApp.controller('B', function($scope) {
$scope.$on("test",function(){
alert("B has recieved it");
});
});
myApp.controller('C', function($scope) {
$scope.$on("test",function(){
alert("C has recieved it");
});
});