A simple Google search turned up a solution which seems to match exactly what you want to do: https://github.com/angular/angular/issues/4112
On Thu, Jun 30, 2016, 06:56 Simon Azzopardi <[email protected]> wrote: > Another Service is calling that method: >> >> > import { Injectable } from '@angular/core'; > import { CanActivate, > Router, > ActivatedRouteSnapshot, > RouterStateSnapshot } from '@angular/router'; > import { AuthService } from './auth.service'; > > import { LoginResponseModel } from './Login/loginResponseModel'; > > @Injectable() > export class AuthGuard implements CanActivate{ > > constructor(private _authService: AuthService, private _router: > Router) {} > > canActivate( > > next: ActivatedRouteSnapshot, > state: RouterStateSnapshot > > ){ > > if(this._authService.subscribeIsUserLoggedIn()){ > return true; > }else{ > this._router.navigate(['/login']); > return false; > } > } > } > > -- > You received this message because you are subscribed to the Google Groups > "AngularJS" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/angular. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
