Pratibha Pratibha - 1 year ago 456
AngularJS Question

Angular $rootScope.$broadcast() event caught twice in controller

Broadcating event on button click :-

$scope.onButtonClick = function(){

And catching event in another controller :-


But it caught twice even though it fired only once. Why is that?

Answer Source

As it turned out the multiple controllers were instantiated due to ng-controller declaration in html and also as part of state setup for ui-router.

The solution is to remove on the the declaration.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download