Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. import { Injectable } from '@angular/core';
  2. import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot } from '@angular/router';
  3. import { Observable } from 'rxjs';
  4.  
  5. @Injectable({
  6. providedIn: 'root',
  7. })
  8. export class SuccessGuard implements CanActivate {
  9.  
  10. constructor(private router: Router) { }
  11.  
  12. canActivate(
  13. next: ActivatedRouteSnapshot,
  14. state: RouterStateSnapshot): Observable<boolean> | Promise<boolean> | boolean {
  15. if (this.router.url === `/`) {
  16. this.router.navigate([`/home`]);
  17. return false;
  18. }
  19. return true;
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement