src/app/guards/app-state.guard.ts
Methods |
constructor(router: Router, app: AppState)
|
Defined in src/app/guards/app-state.guard.ts:6
|
canActivate |
canActivate()
|
Defined in src/app/guards/app-state.guard.ts:9
|
Returns :
boolean
|
import { Injectable } from '@angular/core';
import { Router, CanActivate } from '@angular/router';
import { AppState } from '../stores/app-state.store';
@Injectable()
export class AppStateGuard implements CanActivate {
constructor(private router: Router, private app: AppState) {}
canActivate() {
if (this.app.isValid) {
console.log('Passed app state guard');
return true;
}
console.log('Failed app state guard');
this.router.navigate(['/start']);
return false;
}
}