From 8ce28dbafa6ba73bb6e3280cb905016a86e39abe Mon Sep 17 00:00:00 2001 From: Arno Chauveau Date: Tue, 30 May 2023 13:19:01 +0200 Subject: [PATCH] docs(router): correct references to guard services (#50514) PR Close #50514 --- aio/content/guide/router.md | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) 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], }