0

I am currently broadcasting to a child scope(from one parent controller to a child controller). In the $scope.$on

app.controller('myCtrl')

    $scope.$on('broadcastName', function(e, d){       
       //I want to be able to access myCtrl's scope here even though
       //the broadcast comes from another controller 
    });

I want to have access to the current controllers scope that catches the broadcast with in my $scope.$on function, not the parent controller that emitted the broadcast.

I figured the answer out as I was writing up the question.

Fueled By Coffee
  • 2,467
  • 7
  • 29
  • 43
user3738936
  • 936
  • 8
  • 22

1 Answers1

0

I hope this saves someone else some time

 app.controller('myCtrl')

 $scope.$on('broadcastName', function(e, d){
   /* if you want the scope of the controller that made the broadcast */
   console.log('parent scope', e.targetScope);
   /* if you want the scope of the controller that caught the broadcast it is just your basic scope */
   console.log('child scope', $scope);
 });
Ivan Chernykh
  • 41,617
  • 13
  • 134
  • 146
user3738936
  • 936
  • 8
  • 22