The CanActivate
and CanDeactivate
interfaces can be used to implement the same type of logic that the removed events ionViewCanEnter
and ionViewCanLeave
did.
例子:
@Injectable()
export class AuthGuard implements CanActivate {
constructor(private authService: AuthService) {}
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
return this.authService.isAuthenticated();
}
}