-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Accessing resolved data in Transition state's parents #2946
Comments
We now expose the low level $transitions.onSuccess({}, function(trans) {
$rootScope.$title = trans.getResolveValue('$title');
// Array of PathNode(s) for the To-Path
let toPathNodes = trans.treeChanges().to;
function getBreadcrumb(node) {
// '$title' Resolvable(s), or undefined
var titleResolvable = node.resolvables.filter(r => r.token === '$title')[0];
return !titleResolvable ? null : {
title: titleResolvable.data,
href: $state.href(node.state)
}
}
// array of title/href tuples
$rootScope.$breadcrumbs = toPathNodes.map(getBreadcrumb).filter(angular.identity);
}); |
That's perfect, thank you for the quick response and thorough example. |
@christopherthielen Thanks for your answer. Sometimes I need to get resolvables from state instead of trans.treeChanges().to and I do not know how to do so. |
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:
and a directive where I attempt to basically gather breadcrumb information about the current hierarchy:
How can I get the resolved value of
$title
on the current state's parent?The text was updated successfully, but these errors were encountered: