$scope.$on custom events not working for ionic controllers of ion-view

I saw a lot of posts regarding the $ionView.* events not getting picked up by $scope.$on, but I am finding even normal events are not picked up. I’'ve used AngularjS quite a bit, but new to ionic; this observation doesn’t make any sense.

To be able to catch and event in my controller fired via


in another controller, I have to use:

$scope.$parent.$on('myevent', ... );

I am using ionic 1.3.2, and angular-ui router. I defined the controller and the templateUrl in the state definition in app.js.


$scope.$broadcast(‘myevent’,data) and $scope.$on(‘myevent’, function(event, data) {}); will work. Why are you using $rootScope?

Because my recipient scope is not a child of the sending scope, nor is it an ancestor. $scope.$broadcast will only send the event to this scope (as you noted) and child scopes. I’m wondering if it has something to do with isolate scopes.

try this
$rootScope.$emit(‘myEvent’, notification);
$rootScope.$on(‘myEvent’, function (event, obj)
if your using broadcast then the event will accessible to all the scope,while using emit you can limit the event on a particular scope only

Thanks for your reply, but your information is not accurate. $emit sends the event up the scope chain $broadcast sends it down. Both are limited, depending on where your originating $scope is in the scope chain.

1 Like

Sorry for my wrong information and thanks for your valuable information