I would like to check in the root component of AppComponent whether the child component is loaded. By a child component, I mean the component that corresponds to the current URL, this component will be loaded into the router-outlet directive in the AppComponent component template. In the route of the child component there is an asynchronous guard canActivate, it checks if you can go to this state.

I would like to execute my code in the AppComponent component after guard canActivate runs and the child component is ready to be shown.

    1 answer 1

    Can I try to use the injected Router and monitor it to get the status?

     class AppComponent{ constructor(router: Router) { const state: RouterState = router.routerState; const root: ActivatedRoute = state.root; const child = root.firstChild; const id: Observable<string> = child.params.map(p => p.id); id.subscribe(id => checkforId(id)); }