Function call using $on cannot be from the $scope

Viewed 86

I am using a normal $rootScope.$broadcast to transfer control to a different controller. The other controller is trying to call a function based on this. The question is can this function that is being called a $scope function or it has always to be a private function within the controller. So when I write the below:

  $scope.$on('aRequest',function(){console.log('it works')});

It works as expected. But when I write:

 $scope.$on('aRequest',$scope.someFunction());

It doesn't work. I don't see a syntax error in the console as well. Am I missing something?

Like to add that when this call is made like below as well it works:

 $scope.$on('aRequest',iWorkProperly);
 var iWorkProperly = function(){};
1 Answers
Related