I am currently utilizing ui-router
version 0.2.13. According to this page:
All resolves on one state will be resolved before moving on to the next state, even if they aren't injected into that child
Additionally, all resolves for all the states being entered are triggered and resolved before the transition will enter any states (regardless of the resolve being injected somewhere)
However, in my particular scenario, the resolve function for the child state is being executed before the resolve promise for the parent is resolved. How can this be happening?
Take a look at the code below:
$stateProvider
.state('route1', {
url: "/route1",
templateUrl: "route1.html",
resolve: {
parent: ["$timeout", "$q", function ($timeout, $q) {
var d = $q.defer();
$timeout(function () {
d.resolve();
}, 5000);
return d.promise;
}]
}
})
.state('route1.list', {
url: "/list",
templateUrl: "route1.list.html",
controller: function ($scope) {
$scope.items = ["A", "List", "Of", "Items"];
},
resolve: {
child: function () {
alert("I'm shown before `parent` resolved");
}
}
});
When navigating to /route1/list
, the alert message is displayed immediately without waiting for the parent resolve promise to be resolved after 5 seconds.