Вот мой app.routing.ts
export const appRoutes: Routes = [
{
path: '',
canActivate: [MyAuthGuard],
canActivateChild: [MyAuthGuard],
children: [
{
path: '',
redirectTo: '/my-default-page',
pathMatch: 'full'
},
{
path: 'some-feature',
redirectTo: '/some-route-defined-in-other-module'
}
]
},
{ path: '404', component: NotFoundComponent },
{ path: '**', redirectTo: '/404' }
];
Если я перейду к localhost: 4200 / some-feature, я вижу, что MyAuthGuard.canActivateChild не вызывается, однако, если я изменю app.routing.tsна
export const appRoutes: Routes = [
{
path: '',
canActivate: [MyAuthGuard],
canActivateChild: [MyAuthGuard],
children: [
{
path: '',
redirectTo: '/my-default-page',
pathMatch: 'full'
},
{
path: 'some-feature',
component: MyComponent
}
]
},
{ path: '404', component: NotFoundComponent },
{ path: '**', redirectTo: '/404' }
];
и перейдите к localhost: 4200 / some-feature, теперь я вижу, что MyAuthGuard.canActivateChild вызывается.
Мой вопрос заключается в том, почему MyAuthGuard.canActivateChild не вызывается, когда ребеноктакое перенаправление?