The canActivateChild method is a class-based route-guard method that runs before Angular activates any child route beneath a guarded parent. It receives ActivatedRouteSnapshot and RouterStateSnapshot objects and can use dependency injection, which makes it practical for checks involving services. section 26.2.2
Use the method by following this configuration pattern:
- Define a guard class containing canActivateChild. section 26.2.2
- Return the appropriate guard result; Angular activates the child when the result permits navigation. section 26.2.2
Guarding product child routes
A TermsGuard can protect a parent route containing products and categories children. Its canActivateChild method prompts the user for the categories route, resolves true for Yes, and rejects navigation for No; it can also use Router to redirect.
