I am having an issue with sending data from a service to a controller using $emit. When I log the data in the service, it is present, but when I try to access it in the controller using $rootScope.$on, the data is not showing up.
service.GetTest = function () {
var inside = this;
var promise = $http(
{
method: 'POST',
url: inside.baseUrl + 'Admin/setTest',
contentType: 'application/json'
});
promise.then(function (data) {
console.log(data);
$rootScope.$emit('monitor', data);
})
}
$rootScope.$on('monitor', function (event,data) {
console.log(data);
});