A child route guard controls activation for the child routes belonging to a parent route. Angular invokes it before activating any child, using route snapshots and a boolean, Observable, or Promise result. section 26.2.2
Use a child guard when several child routes share an activation rule:
- Define a function receiving ActivatedRouteSnapshot and RouterStateSnapshot, or prefer a class with canActivateChild for dependency injection. section 26.2.2
- Apply the guard to the parent route through canActivateChild and mapToCanActivateChild; Angular then checks each child navigation. section 26.2.2
- Return true to activate a child and false to cancel navigation; asynchronous checks resolve through an Observable or Promise. section 26.2.2
Guarding product-management children
A parent route containing products and categories can set canActivateChild to mapToCanActivateChild([TermsGuard]). TermsGuard can inspect the requested route, prompt through a message service, and allow or reject activation. The guard can protect only the categories child route while immediately allowing other children. section 26.2.2
