Saturday, 18 August 2018

javascript - Working with $scope.$emit and $scope.$on

How can I send my $scope object from one controller to another using .$emit and .$on methods?



function firstCtrl($scope) {
$scope.$emit('someEvent', [1,2,3]);
}


function secondCtrl($scope) {
$scope.$on('someEvent', function(mass) { console.log(mass); });
}


It doesn't work the way I think it should. How do $emit and $on work?

No comments:

Post a Comment