has something changed between angular 1.2 rc2 and angular 1.2 with regards to broadcast and receiving the broadcast ?
I have what I think is a standard broadcast in a controller in a $watch i.e.
$scope.$watch('changedRequest', function(newValue, oldValue) {
$rootScope.$broadcast('onTestingMe')
});
and I try to receive it in another controller like so
$rootScope.$on("onTestingMe", function () {
alert('I am received');
});
The broadcast seems to work but I never get anything arriving in $on.
I have set the $on and $broadcast on the $rootScope. My watch is on a $scope but this shouldn't be an issue.
I am injecting $rootScope in both controllers.
There are no errors being received in the chrome console.
I am lost, any ideas ?
I did notice the same happening on RC3 but I just put this down to an RC, so I went back to RC2 and thought I would wait for 1.2 Release.... but the same is happening..
EDIT
The only thing I can see that is different is that I am using a ng-include
<div ng-include="template.url" ng-controller="ItemBarCtrl"></div>
Maybe its not rendering quick enough ? As the msg is sent when document is loaded and the controller ItemBarCtrl has the $on ....
I will try and do some testing... Strange issue!
This is an old question, but I came across it searching for a similar problem. Try wrapping your $broadcast
in a $timeout
function with a delay of 100 or so. If the $on
fires, then it's likely the same problem I'm running in to where the $broadcast
fires before the $on
is ready. I'm still investigating the issue for a fix.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With