Closed
Description
This is similar to #2864, but I also need to access parent state's resolved values. I've checked the source code but don't see how the Transition methods could be used to get this data from a parent state.
Given this router definition:
$stateProvider
.state('company', {
url: '/company/:id',
resolve: {
'company': ['$stateParams', 'Company', function($stateParams, Company) {
return Company.findById($stateParams).$promise;
}],
$title: ['company', function(company) {
return company.name;
}]
}
})
.state('company.overview', {
url: '/overview',
resolve: {
$title: function() { return 'Overview'; }
}
});
and a directive where I attempt to basically gather breadcrumb information about the current hierarchy:
$transitions.onSuccess({from: '*.*', to: '*.*'}, function(Transition) {
$rootScope.$title = Transition.getResolveValue('$title');
$rootScope.$breadcrumbs = [];
var state = $state.$current;
while (state) {
if (state.resolve && state.resolve.$title) {
$rootScope.$breadcrumbs.unshift({
title: state.resolve.$title,
href: $state.href(state)
});
}
state = state.parent;
}
});
How can I get the resolved value of $title
on the current state's parent?
Metadata
Metadata
Assignees
Labels
No labels