Reputation: 85
How can I reach the $scope and modify it from inside my $rootScope.$on event handler?
angular.module('Foo')
.controller('BarCtrl', ['$scope', '$rootScope', function ($scope, $rootScope) {
$scope.x = {};
$rootScope.$on('myEvent', function(event, data){
if(data){
//how to reach BarCtrl $scope.x here?
}else{
//same here
}
})
}])
Upvotes: 0
Views: 114
Reputation: 613
simply use $scope
variable
$rootScope.$on('myEvent', function(event, data){
$scope.x = data;
});
Upvotes: 1