Reputation: 1
I got a problem with Angular 5 router. My ParamsResolve is a service which retrieve all the application's settings, so I have to load it first.
In order to do that, I set the call in a resolve service params: ParamsResolve,
I have a guard (RightRouteGuard
) in the feature module StatsModule
that need Params to be resolved first, but when I navigate to the stats path, the guard is resolved before the Params...
My app routing :
const routes: Routes = [
{
path: '',
resolve: {
params: ParamsResolve,
},
canActivate: [LoginRouteGuard],
children: [
{
path: 'stats',
loadChildren: 'app/stats/stats.module#StatsModule',
}
]
},
Feature module routing :
{
path: '',
canActivate: [RightRouteGuard],
data: {
expectedRight: [6, 69]
},
component: ConvertComponent
}
What I missed ? Thanks for your help.
Upvotes: 0
Views: 1528
Reputation: 791
Obviously canActivate will be resolved first since it's intended to do so - canActivate makes sure that whether you're permitted to use the route.
resolve is to fetch the data before navigating to the route.
Thanks
Upvotes: 1