angularjs - $rootScope.$broadcast from controller and $scope.$on in directive is not working 1.2x version -


i'm trying call $rootscope.broadcast controller , want listen in directive

controller:  function startfunction(){    $rootscope.$broadcast('sharingfn'); } startfunction();   directive:   $scope.$on('sharingfn',function(){  console.log('function called"); }     

but directive never called here, doing wrong?

do have live example of code? it's difficult tell problem above example.

one potential reason can think of directive doesn't start listening event until after 'sharingfn' event has been broadcast.


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -