Last active
August 29, 2015 14:25
-
-
Save samny/227a7a2e59a2e20b4259 to your computer and use it in GitHub Desktop.
Wait for promise resolve before triggering route
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular | |
.module('app', ['ui.router']) | |
.config(function ($urlRouterProvider) { | |
$urlRouterProvider.deferIntercept(); | |
}); | |
.run(function ($rootScope, $urlRouter, WaitForThis) { | |
var deRegister = $rootScope.$on('$locationChangeSuccess', function (e) { | |
e.preventDefault(); | |
WaitForThis.init().then(function () { | |
deRegister(); // if this only needs to be checked once, de-register the listener. | |
$urlRouter.sync(); | |
}); | |
}); | |
$urlRouter.listen(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment