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
Post a Comment