AngularJS: how to preventDefault() of an event after promise completes? -


i have code this:

$scope.$on("$locationchangestart", function(event, newpath, oldpath) {      // sync checks     if (!$scope.ispageallowed($location.path()))     {         // prevent default reason         event.preventdefault();     } }); 

when trying resolve promises this:

$scope.$on("$locationchangestart", function(event, newpath, oldpath) {      // async checks     $scope.foopromises().then(function (data) {           // prevent default reason when promises resolved (only if resolved)          event.preventdefault();     }); }); 

i got successfull event (because of async execution) , after while prevented event when promises resolved.

is there way link event promises, prevented after promises being resolved , not streight after function end?

sorry, won't work :-). events purely synchronous.

you're looking $route.resolve. asynchronous resolution/rejection of routes, give controller data or check something.

http://www.egghead.io/video/kr1qz8ik9g8


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -