File tree 2 files changed +5
-12
lines changed
2 files changed +5
-12
lines changed Original file line number Diff line number Diff line change 1
1
// #docregion
2
- import { Injectable } from '@angular/core' ;
3
- import { CanActivate ,
4
- Router ,
5
- ActivatedRouteSnapshot ,
6
- RouterStateSnapshot } from '@angular/router' ;
7
- import { AuthService } from './auth.service' ;
2
+ import { Injectable } from '@angular/core' ;
3
+ import { CanActivate , Router } from '@angular/router' ;
4
+ import { AuthService } from './auth.service' ;
8
5
9
6
@Injectable ( )
10
7
export class AuthGuard implements CanActivate {
11
8
constructor ( private authService : AuthService , private router : Router ) { }
12
9
13
- canActivate (
14
- // Not using but worth knowing about
15
- next : ActivatedRouteSnapshot ,
16
- state : RouterStateSnapshot
17
- ) {
10
+ canActivate ( ) {
18
11
if ( this . authService . isLoggedIn ) { return true ; }
19
12
this . router . navigate ( [ '/login' ] ) ;
20
13
return false ;
Original file line number Diff line number Diff line change @@ -1052,7 +1052,7 @@ h2#guards Route Guards
1052
1052
We'll examine other router guards in a future update to this chapter.
1053
1053
:marked
1054
1054
We can have multiple guards at every level of a routing hierarchy.
1055
- The router checks the `CanDeactive ` guards first, from deepest child route to the top.
1055
+ The router checks the `CanDeactivate ` guards first, from deepest child route to the top.
1056
1056
Then it checks the `CanActivate` guards from the top down to the deepest child route.
1057
1057
If _any_ guard returns false, pending guards that have not completed will be canceled,
1058
1058
and the entire navigation is canceled.
You can’t perform that action at this time.
0 commit comments