gentos gentos -5 years ago 183
AngularJS Question

angularJs, $rootScope.$emit() returns an object of data

I am trying to expose a response from the service to the controller via $rootScope.$emit('name',, but it doesn't work.

My service:

/**API Post for user login*/
function login(username,password){
return $'/api/login/',{
}).then(loginSuccessFn, loginErrorFn);

function loginSuccessFn(response, status, headers, config){

window.location = '/';
function loginErrorFn(response, status, headers,config){


My Controller:

//Catching the Authentication.login errorFNn
$rootScope.$on('errorLogin', function(p){
vm.isSuccess = p;

and this is what happens in the view:


can someone help me out

Answer Source


$rootScope.$on('errorLogin', function(p){
    vm.isSuccess = p;


$rootScope.$on('errorLogin', function(e, p){
    vm.isSuccess = p;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download