问题
router details:
this is the route details of a feature module, being lazy loaded. the route is /customers
const routes: Routes = [
{ path: '',
component: CustomersComponent,
children: [
{ path: '', component: CustomersListComponent },
{ path: ':id', component: CustomersDetailsComponent,
resolve: {
xxx: CustomerResolve1
}
,children: [
{ path: ':module', component: CustomersModuleDetailsComponent,
resolve: {
xxx: CustomerResolve2
}
}
] }
]
}
];
in the 2 resolvers, i just write to the console that i've reached the resolver.
if i enter the following url:
http://localhost:4200/customers/45/invoices
the 2 resolvers are executed.
if i press a button that executes the following in my ts:
this.router.navigate(['customers','100','invoices']);
only the first resolver is executed !
as my inner most component "CustomersModuleDetailsComponent" shows information based on the url, it's not being refreshed as the resolver for that component isn't being executed.
any suggestions ? (beside changing the resolver to a guard) (and besides transferring the id from the father component to the son component via @input, or eventEmitter)
Thanks
回答1:
I have the same issue. It seems there is a bug in Angular Router.
The children's resolvers are not triggered in this case when parent route param is modified.
来源:https://stackoverflow.com/questions/41496499/resolve-not-called-for-child-routes-in-angular-2