Reputation: 689
I would need to have some settings added to a child route using the aurelia router.
If I add the settings parameter to a main route, when the navigation pipeline goes through the authorize step, I can retrieve the settings using the navigationInstruction.config.settings property.
When navigating to a child route, the authorizeStep gets the route information of the main route with its settings and some information about the child route but no settings...
For instance: if I have the following main route defined in app.ts
{name: 'user', settings: {bla: 'user'}...}
and the following child route defined in user.ts:
{name: 'useredit', settings: {bla: 'edit'}...}
Whether I navigate to the user or useredit route, I always get the following settings object : {bla: 'user'} as the navigation instruction is related to the main route.
How could I get the {bla: 'edit'} settings information when navigating to edit?
I sure hope the answer won't just be "child routes cannot have settings"... :)
thanks!
Upvotes: 1
Views: 741
Reputation: 11990
By calling navigationInstruction.getAllInstructions()
, you should get 2 instructions. The first is related to the main route, and the second to the child route, which contains contains the settings: {bla: 'edit'}
. For instance:
class AuthorizeStep {
run(navigationInstruction, next) {
// all the instructions here!
let instructions = navigationInstruction.getAllInstructions();
// ... do something
return next();
}
}
Hope this helps!
Upvotes: 3