onLogin() {
    this._route.params.subscribe(params => {
        let originalUrl = params['from'];
        this._router.navigate([originalUrl]);
    });
}

You may need to adjust originalUrl to match the base of your application.

On Mon, Jul 4, 2016 at 6:14 AM, Simon Azzopardi <
[email protected]> wrote:

> Hi Lucas,
>
> I am referring to the Login Component.
>
> Once I get the params, from the *from *parameter for example and it will
> be: localhost/dashboard/clients
>
> How I can tell the this._router to navigate to that url?
>
> On Monday, July 4, 2016 at 12:10:29 PM UTC+2, Lucas Lacroix wrote:
>>
>> Open your browser debugging tools and play around with the location
>> object. Between that and the documentation I already sent you, you should
>> be able to figure it out.
>>
>> On Mon, Jul 4, 2016, 06:08 Simon Azzopardi <[email protected]>
>> wrote:
>>
>>> Hi Lucas,
>>>
>>> Thanks for that.
>>>
>>> I was already there but how can i tell router to navigate with the full
>>> url: localhost:1245/dashboard/clients ?
>>>
>>> Thanks kinds Regards
>>>
>>>
>>> On Monday, July 4, 2016 at 12:01:46 PM UTC+2, Lucas Lacroix wrote:
>>>
>>>> Hi Simon,
>>>> This has nothing to do with Angular2 and is basic Javascript
>>>> programming. I would suggest that you take a look at some Javascript
>>>> tutorials if you need help in that arena. If you need help specifically
>>>> with Angular2, this is the forum for you.
>>>>
>>>> That being said...
>>>> this._route.navigate(['/login'], {
>>>>     from: location.toString(),
>>>>     ....
>>>> });
>>>>
>>>> Then, follow the tutorial here (
>>>> https://angular.io/docs/ts/latest/guide/router.html#!#route-parameters)
>>>> to get the parameter back in to your login component.
>>>>
>>>
>>>> On Mon, Jul 4, 2016 at 5:48 AM, Simon Azzopardi <
>>>> [email protected]> wrote:
>>>>
>>>>> Hi Lucas,
>>>>>
>>>>> I want the component name so that I can pass it as queryParams to the
>>>>> login component and then once log in, user will be taken to the component
>>>>> as in the query params, using the router navigate.
>>>>>
>>>>> Any idea how I can achieve this please?
>>>>>
>>>>>
>>>>>
>>>>> On Monday, July 4, 2016 at 3:54:35 AM UTC+2, Lucas Lacroix wrote:
>>>>>>
>>>>>> I sent you the documentation already.
>>>>>>
>>>>>> On Sun, Jul 3, 2016, 09:58 Simon Azzopardi <
>>>>>> [email protected]> wrote:
>>>>>>
>>>>>>> HI Lucas,
>>>>>>>
>>>>>>> thank you for your reply.
>>>>>>>
>>>>>>> Do you have an example how I can use the location object to get the
>>>>>>> current url?
>>>>>>>
>>>>>>> Thank you
>>>>>>>
>>>>>>>
>>>>>>> On Saturday, July 2, 2016 at 8:36:58 PM UTC+2, Lucas Lacroix wrote:
>>>>>>>
>>>>>>>> Use the location object:
>>>>>>>> http://www.w3schools.com/jsref/obj_location.asp
>>>>>>>> Then, when you redirect to the login, pass the current URL as an
>>>>>>>> encoded parameter to the login URL.
>>>>>>>>
>>>>>>>> On Sat, Jul 2, 2016 at 9:41 AM, Simon Azzopardi <
>>>>>>>> [email protected]> wrote:
>>>>>>>>
>>>>>>> Any idea guys please?
>>>>>>>>>
>>>>>>>>> On Friday, July 1, 2016 at 2:01:12 PM UTC+2, Simon Azzopardi wrote:
>>>>>>>>>>
>>>>>>>>>> Hi guys,
>>>>>>>>>>
>>>>>>>>>> hope you're fine.
>>>>>>>>>>
>>>>>>>>>> I have a dilemma how I can navigate users back to the previous
>>>>>>>>>> url where they was after they were redirected to the login page.
>>>>>>>>>>
>>>>>>>>>> Currently, I have this AuthGuard service:
>>>>>>>>>>
>>>>>>>>>> import { Injectable }             from '@angular/core';
>>>>>>>>>> import { CanActivate,
>>>>>>>>>>          Router,
>>>>>>>>>>          ActivatedRouteSnapshot,
>>>>>>>>>>          RouterStateSnapshot }    from '@angular/router';
>>>>>>>>>> import { AuthService }            from './auth.service';
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> import {Observable} from 'rxjs/Observable';
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> @Injectable()
>>>>>>>>>> export class AuthGuard {
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>     constructor(private _authService: AuthService, private
>>>>>>>>>> _router: Router) {}
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>     canActivate(): Observable<boolean>{
>>>>>>>>>>         return this._authService.checkIfUserIsLoggedIn()
>>>>>>>>>>         .map((result) => {
>>>>>>>>>>
>>>>>>>>>>  if (result["_body"] == "true") {
>>>>>>>>>>
>>>>>>>>>>  return true;
>>>>>>>>>>  } else {
>>>>>>>>>>  this._router.navigate(['/login'], { queryParams: {message: 'You
>>>>>>>>>> must be logged in to access Dashboard!'}});
>>>>>>>>>>  return false;
>>>>>>>>>>  }
>>>>>>>>>>  });
>>>>>>>>>>     }
>>>>>>>>>> }
>>>>>>>>>>
>>>>>>>>>> Then, I assigned it accordingly to my dashboard routes:
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> export const DashboardRoutes: RouterConfig = [
>>>>>>>>>>     {
>>>>>>>>>>         path: '',
>>>>>>>>>>         redirectTo: '/dashboard',
>>>>>>>>>>         terminal:true
>>>>>>>>>>     },
>>>>>>>>>>   {
>>>>>>>>>>     path: '/dashboard',
>>>>>>>>>>     component: DashboardComponent,
>>>>>>>>>>     canActivate: [AuthGuard],
>>>>>>>>>>     children:[
>>>>>>>>>>         {path: '', component: DashboardHomeComponent, canActivate
>>>>>>>>>> : [AuthGuard]},
>>>>>>>>>>         {path: '/jobs', component: JobsComponent, canActivate: [
>>>>>>>>>> AuthGuard]}
>>>>>>>>>>     ]
>>>>>>>>>>   },
>>>>>>>>>> ];
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Now I would like to know how I can get the previous url ater they
>>>>>>>>>> were redirected to the login, to login first.
>>>>>>>>>>
>>>>>>>>>> Any ideas please?
>>>>>>>>>>
>>>>>>>>>> thank you in advance.
>>>>>>>>>>
>>>>>>>>>> Kind Regards
>>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> 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.
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> Lucas Lacroix
>>>>>>>> Computer Scientist
>>>>>>>> System Technology Division, MEDITECH <http://ehr.meditech.com>
>>>>>>>> 781-774-2293
>>>>>>>>
>>>>>>> --
>>>>>>> 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.
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Lucas Lacroix
>>>> Computer Scientist
>>>> System Technology Division, MEDITECH <http://ehr.meditech.com>
>>>> 781-774-2293
>>>>
>>> --
>>> 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.
>



-- 
Lucas Lacroix
Computer Scientist
System Technology Division, MEDITECH <http://ehr.meditech.com>
781-774-2293

-- 
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