File

src/app/guards/app-state.guard.ts

Index

Methods

Constructor

constructor(router: Router, app: AppState)
Parameters :
Name Type Optional
router Router no
app AppState no

Methods

canActivate
canActivate()
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;
  }
}

results matching ""

    No results matching ""