javascript - Broadcasting a function from another controller does not work, but only in production -


this weirdest problem have had far angularjs. our website constructed of different routes. each route has view , controller, , there parent controller called mainctrl. in index.html import controllers have. @ point re-routing child route (let's call /iframe iframectrl controller) , then, when try dispatch event name mainctrl downwards children (the broadcasted function in iframectrl), nothing happens (locally it's fine, problem in production). not sure if problem that after change route function iframectrl hasn't been loaded yet, load in index.html thought enough, , said, work locally.

this code mainctrl:

globalvariables.broadcastanimatebar({stage : data.progress}); 

this code factory in app.'s

globalvariablesservice.broadcastanimatebar = function(stage) {     $rootscope.$broadcast('animatebar',stage); } 

and code in iframectrl

$scope.$on('animatebar', function(event,args){ . . . }) 

any ideas how go it?

thank you, mila

i managed work adding timeout broadcast

  $timeout(function(){        $rootscope.$broadcast('animatebar',stage);   }, 1000); 

Comments