1

Currently my application will set a XHR to server to get user information.

I have set CanActivate and CanActivateChild like:

{
    path: '',
    canActivate: [AuthService],
    canActivateChild: [AuthService],
    children: [
        {
            path: 'a',
            component: AComponent,
        },
        { path: 'b1', component: B1Component },
        { path: 'b2', component: B2Component },
        {
            path: 'c',
            component: CComponent,
            pathMatch: 'full',
        },
        { path: 'd/create', component: DComponent },
        { path: 'd/:id', component: DComponent, pathMatch: 'full' },
    ]
}

When I go to /a that XHR sent twice so Angular will run CanActivate and CanActivateChild at the same time in parallel but not CanActivate first then CanActivateChild?

tom10271
  • 4,222
  • 5
  • 33
  • 62
  • did you put your url to browser url like `domain.com/parent/a`, if you do this, it'll trigger twice. once for `parent`, and once for `a`. – Tiep Phan May 18 '17 at 03:32

0 Answers0