Inside one of my Angular controllers, I have this:
// controller A
$rootScope.$on("myEventFire", function(event, reload) {
someAction();
});
In another controller I have this:
// controller B
$scope.openList = function(page) {
$rootScope.$broadcast('myEventFire', 1);
}
Now, this is a single-page app. When I go to controller A initially and try triggering this event, someAction() is going to be executed once. If I navigate away and come back again to controller A and do the same thing, someAction() gets executed twice. If I do it again, it happens three times and so on. What am I doing wrong here?