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

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...