resolução de ui-router angular para o estado pai
No meu estado pai, tenho umresolve
. Atualmente, eu não injeto oresolver chave em qualquer estado filho.
Eu assumi que meu estado filho não esperaria que essa resolução / promessa fosse resolvida. Mas quando defino um tempo limite, posso ver que meu estado filho espera.
Esse comportamento é correto?
.config(function ($stateProvider, $urlRouterProvider, STATES) {
$stateProvider
.state(STATES.ROOT, {
abstract: true,
template:'<div ui-view=""></div>',
resolve: {
UserService: 'UserService',
userDetails: function(UserService){
return UserService.getUserProfile();
}
}
})
.state(STATES.BILLING, {
url: '/bill/checkClientContext.html',
templateUrl: 'bill/checkClientContext.html',
controller: 'BillingController'
})
UserService.js
'use strict';
angular.module('nabc.data')
.service('UserService', ['AjaxService', '$timeout','$q', function(AjaxService, $timeout, $q) {
var getUserProfile = function() {
var promise = AjaxService.get('userProfile');
var deferred = $q.defer();
$timeout(function(response){
deferred.resolve(response);
}, 5000);
return deferred.promise;
};
return {
getUserProfile: getUserProfile
};
}]);
Como você pode ver acima, oBillingController
não injeta emuserDetails
. Mas quando defino um tempo limite no userService, vejo que meu estado de cobrança aguarda.