0

Hi I have a problem in Angular where $scope.$broadcast is only updating a listening value once the page has been refreshed once:

One controller:

$rootScope.$broadcast('myVar', myValue);

Listener:

$scope.$on('myVar', function(event, myValue) {
    console.log(myValue);
    $scope.myValue= myValue;
});

It works if I refresh the page once, but on initial load the listener is not working? Any ideas?

Davin Tryon
  • 66,517
  • 15
  • 143
  • 132
rjmacarthy
  • 2,164
  • 1
  • 13
  • 22

1 Answers1

0

I have solved the problem, using $window.location.reload(); it appeared that I needed to reload the controller to re-initiate the listener.

rjmacarthy
  • 2,164
  • 1
  • 13
  • 22