javascript - Receive events with Angular in order -



javascript - Receive events with Angular in order -

i have problem managing events in angularjs. in service dispatch events next line of code :

$rootscope.$emit("fnh."+this.status, flownodehelper);

in service "s1" receive event in next way :

$rootscope.$on('fnh.ready', function(event, flownodehelper) { flownodehelperservice.setactive(flownodehelper); }); $rootscope.$on('fnh.active', function(event, flownodehelper) { flownodehelperservice.setcompleting(flownodehelper); }); $rootscope.$on('fnh.completing', function(event, flownodehelper) { flownodehelperservice.setcompleted(flownodehelper); }); $rootscope.$on('fnh.completed', function(event, flownodehelper) { flownodehelperservice.setclose(flownodehelper); });

in directive receive event in same way :

$rootscope.$on('fnh.ready', function(event, flownodehelper) { console.log(flownodehelper + " status ready"); }); $rootscope.$on('fnh.active', function(event, flownodehelper) { console.log(flownodehelper + " status active"); }); $rootscope.$on('fnh.completing', function(event, flownodehelper) { console.log(flownodehelper + " status completing"); }); ...

in service "s1" when receive event "fnh.ready", phone call flownodehelper.setcompleting() function dispatch event of type fnh.active $rootscope.$emit. same thing go active status completing status, etc. workflow going on.

in "s1" receive events in order ready, active, completing, ... in directive receive them in other order : completed completing, active, ready !!

how can receive events in same time in "s1" service , in directive please ?

thanks lot help

clement

strange, works if next each phone call flownodehelperservice in s1 :

$timeout(function() { flownodehelperservice.setactive(flownodehelper); }, 1);

javascript angularjs javascript-events angularjs-directive angularjs-service

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -