Home AngularJs - $emit wait a promise
Reply: 0

AngularJs - $emit wait a promise

user674 Published in April 26, 2018, 8:48 pm

I'm using $rootScope.$emit to call a function inside another controller.

// Call

// 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.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.252499 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO