docs(router): changes suggested by Deb Kurata in #1808

This commit is contained in:
Ward Bell 2016-07-06 01:11:00 -07:00
parent 962b215048
commit d1dd2b82f4
2 changed files with 5 additions and 12 deletions

View File

@ -1,20 +1,13 @@
// #docregion
import { Injectable } from '@angular/core';
import { CanActivate,
Router,
ActivatedRouteSnapshot,
RouterStateSnapshot } from '@angular/router';
import { AuthService } from './auth.service';
import { Injectable } from '@angular/core';
import { CanActivate, Router } from '@angular/router';
import { AuthService } from './auth.service';
@Injectable()
export class AuthGuard implements CanActivate {
constructor(private authService: AuthService, private router: Router) {}
canActivate(
// Not using but worth knowing about
next: ActivatedRouteSnapshot,
state: RouterStateSnapshot
) {
canActivate() {
if (this.authService.isLoggedIn) { return true; }
this.router.navigate(['/login']);
return false;

View File

@ -1052,7 +1052,7 @@ h2#guards Route Guards
We'll examine other router guards in a future update to this chapter.
:marked
We can have multiple guards at every level of a routing hierarchy.
The router checks the `CanDeactive` guards first, from deepest child route to the top.
The router checks the `CanDeactivate` guards first, from deepest child route to the top.
Then it checks the `CanActivate` guards from the top down to the deepest child route.
If _any_ guard returns false, pending guards that have not completed will be canceled,
and the entire navigation is canceled.