Take a look at the first plunkr.

On Thu, Jun 30, 2016, 07:31 Simon Azzopardi <[email protected]>
wrote:

> Hi Lucas,
>
> I don't see an actual solution for my problem.
>
>
> On Thursday, June 30, 2016 at 1:19:16 PM UTC+2, Simon Azzopardi wrote:
>>
>> of DrClick?
>>
>>
>> On Thursday, June 30, 2016 at 1:14:20 PM UTC+2, Lucas Lacroix wrote:
>>>
>>> Redirecting to another component when login is required.
>>>
>>> On Thu, Jun 30, 2016, 07:13 Simon Azzopardi <[email protected]>
>>> wrote:
>>>
>>>> For which one you referring to as a solution?
>>>>
>>>>
>>>> On Thursday, June 30, 2016 at 1:07:04 PM UTC+2, Lucas Lacroix wrote:
>>>>
>>>>> 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.
>>>>
>>> --
> 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.

Reply via email to