Why does ChildActivationStart event trigger eventhough we don't have a child route in Angular?

柔情痞子 提交于 2019-12-10 22:08:44

问题


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:

  1. Navigation Start,
  2. Routers Recognized,
  3. Guards Check Start,
  4. Child Activation Start, <-----
  5. Activation Start,
  6. Guards Check End,
  7. Resolve Start,
  8. Resolve End,
  9. Activation End,
  10. Child Activation End, <-----
  11. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!