2

I have a Guard for my parent route that isn't always called when viewing the child routes. It is called when the first child is loaded, but if I switch to another child within the same parent, the parent's Guard isn't referenced again. Here's what I have:

export const AppRoutes: RouterConfig = [
    {
        path: 'app',
        component: AppComponent,
        canActivate: [LoggedInGuard],
        children: [
            {path: 'child1', component: Child1Component, canActivate: [AuthGuard]},
            {path: 'child2', component: Child2Component, canActivate: [AuthGuard]},
            {path: 'error/:status', component: ErrorComponent}
        ]
    }
];

Is there a way to make sure LoggedInGuard is called every time I switch between child1 and child2?

SnoopDougg
  • 1,467
  • 2
  • 19
  • 35

1 Answers1

1
canActivateChild: [LoggedInGuard] 

Is arrived , so you can achieve this by canActivateChild of router.

Niyaz
  • 2,677
  • 3
  • 21
  • 40