Answer the question
In order to leave comments, you need to log in
How to get data from resolve in TemplateProvider?
The essence of the gap is as follows:
you need to get the object from resolve, and check its role, if the role is "x" give the template "x" if "y" - in turn, the template "y" ..
State receives resolve only after the template is loaded. What are the solutions?
I will be grateful
.state('person', {
abstract: true,
url: "/id{id}",
views: {
'header': {
templateUrl: "modules/authorization/header_view.html",
controller: "authorizationCtrl",
resolve: {
authorizationService: 'authorizationService'
}
},
'content': {
templateProvider: ['$stateParams', 'personService', function($stateParams, personService) {
return 'modules/person/lawyer_view.html';
}],
controller: "personCtrl",
resolve: {
personService: 'personService',
profile: ['$stateParams', 'personService', function($stateParams, personService) {
var userId = $stateParams.id;
console.log('second');
return personService.getUser(userId);
}]
}
}
}
})
Answer the question
In order to leave comments, you need to log in
Recent versions of ui-router support locals from the resolve section in templateProvider.
Check your version and try to do
templateProvider: ['$stateParams', 'profile', function($stateParams, profile) {
return 'modules/person/lawyer_view.html';
}],
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question