I'm using $rootScope.$emit to call a function inside another controller.
// Call
$rootScope.$emit('validarDadosBasicos');
// Declaration
$rootScope.$on('validarDadosBasicos', function(event) {
consistirDadosBasicos().then(result => {
vm.factory.abasValidas.dadosBasicos = result;
});
});
consistirDadosBasicos is a async function that return a promise.
After execute "validarDadosBasicos" I need to execute a lot of validations, but I need to wait this function return.
I'ts possible to return a promise inside $on? Are there a some way to force $emit to wait this return.