问题
I defined a router for an Angular project. My router configuration is as follows:
export const routes: Routes = [
{
path: '',
component: AppComponent,
},
{
path: 'hello',
component: HelloComponent,
},
];
export const routing: ModuleWithProviders = RouterModule.forRoot(routes, { enableTracing: true });
When I run the project, I see the router lifecycle events triggered in the following order:
- Navigation Start,
- Routers Recognized,
- Guards Check Start,
- Child Activation Start, <-----
- Activation Start,
- Guards Check End,
- Resolve Start,
- Resolve End,
- Activation End,
- Child Activation End, <-----
- Navigation End
In this list, I see Child Activation Start and Child Activation End events, too. However, I do not have a child route. Why those events trigger anyways?
To see the router events in action please check the console output of the following link:
https://stackblitz.com/edit/angular-khjkwg?file=app%2Fapp.routing.ts
Thanks.
来源:https://stackoverflow.com/questions/49866278/why-does-childactivationstart-event-trigger-eventhough-we-dont-have-a-child-rou