javascript - angular controllers - two way broadcasting -


i have controller wraps ui-router , control flow (like menu bar). when user press on menu item, there function changes ui-router state , broadcast event inner controllers. every inner controller inside ui-router can listen , act event. inner controllers making validation on event if validation fails cannot undo state change. idea how solve problem? thanks

update: using ui-router $statechangestart event approach still incomplete. problem is, main controller hosts ui-router , menu bar has progress bar. main controller registered $statechangestart , taking care of progress bar, child view register event preventing default. means controllers in inconsistent mode. main controller has took care of progress bar , view did not changed. please advise

the ui-router issues $statechangestart event.

your controllers can use event.preventdefault() prevent transition happening.

$scope.$on('$statechangestart',     function(event, tostate, toparams, fromstate, fromparams){         if (notok ) {             event.preventdefault();         }; }) 

for more information see, ui-router state.$state api reference -- events - $statechangestart


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -