diff --git a/aio/content/guide/router.md b/aio/content/guide/router.md index 26e4e89b768..92d97bf9528 100644 --- a/aio/content/guide/router.md +++ b/aio/content/guide/router.md @@ -349,7 +349,7 @@ The following route guards are available in Angular: To use route guards, consider using [component-less routes](api/router/Route#componentless-routes) as this facilitates guarding child routes. -Create a service for your guard: +Create a file for your guard: @@ -357,28 +357,24 @@ ng generate guard your-guard -In your guard function, implement the guard you want to use. -The following example uses `canActivate` to guard the route. +In your guard file, add the guard functions you want to use. +The following example uses `canActivateFn` to guard the route. -export const yourGuard: CanActivateFn = ( +export const yourGuardFunction: CanActivateFn = ( next: ActivatedRouteSnapshot, state: RouterStateSnapshot) => { // your logic goes here } - - In your routing module, use the appropriate property in your `routes` configuration. Here, `canActivate` tells the router to mediate navigation to this particular route. - - { path: '/your-path', component: YourComponent, - canActivate: [yourGuard], + canActivate: [yourGuardFunction], }