次のようなコードがあります。
$scope.$on("$locationChangeStart", function(event, newPath, oldPath) {
// Do some sync checks
if (!$scope.isPageAllowed($location.path()))
{
// Prevent default for some reason
event.preventDefault();
}
});
このように解決しようとするとpromises:
$scope.$on("$locationChangeStart", function(event, newPath, oldPath) {
// Do some async checks
$scope.fooPromises().then(function (data) {
// Prevent default for some reason when promises resolved (only if resolved)
event.preventDefault();
});
});
event(非同期実行のため)成功し、しばらくすると解決されなくeventなりました。promises
eventmyとリンクする方法はありpromisesますか?関数が終了した後ではなく、約束が解決された直後に防止されますか?