Reputation: 9859
I have this simple test setting: a route A
with a parameter parA
, and a subroute B
with parameter parB
.
'A' : ngRoute
(
path : '/A/:parA',
enter: (RouteEnterEvent e)
{
print ('ENTERED A');
e.parameters.keys.forEach(print);
},
mount:
{
'B' : ngRoute
(
path: '/B/:parB',
enter: (RouteEnterEvent e)
{
print ('ENTERED B');
e.parameters.keys.forEach(print);
}
)
}
)
When I go to /#/A/1234/B/5678
I'd expect to get
Entered B
parA
parB
Instead I get
Entered A
parA
Entered B
parB
Meaning that a component created in B
whose constructor has a RouteProvider
can't access the parameter parA
.
Upvotes: 2
Views: 150
Reputation: 657248
Seems to be related to this issue https://github.com/angular/route.dart/issues/85. Maybe the workaround listed there works for you too.
copied from the issue:
As a current workaround I have a helper method that goes through all parent routes and adds them to the RouteEvent.
/// Adds the parameters of all parent routes to [e].
RouteEvent _addParentParams(RouteEvent e) {
// Function to recursively get the parents.
Function recursiveAddParentParams;
recursiveAddParentParams = (Route route) {
// Set the parent parameters to the event.
e.parameters.addAll(route.parameters);
if (route.parent != null) {
recursiveAddParentParams(route.parent);
}
};
recursiveAddParentParams(e.route.parent);
return e;
}
Upvotes: 1