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.
Comments
Post a Comment