Thomas Zuberbühler Thomas Zuberbühler - 1 year ago 134
TypeScript Question

Navigate relative with Angular 2 Router (Version 3)

How to navigate relative from

within a component using
without string concatenation and specifying

I've added an own answer below. Please feel free to suggest a better answer. ;-) I guess there are better approaches.

Answer Source

After doing some more research I came across with

this.router.createUrlTree(['../step2'], {relativeTo: this.activatedRoute});


this.router.navigate(['../step2'], {relativeTo: this.activatedRoute});

First approach (Router.createUrlTree API) did not work for me, i.e. nothing happened. Second approach (Router.navigate API) works.

However, second approach uses NavigationExtras (second argument) which is documented with @experimental. Hopefully there won't be big changes with the next release again... and NavigationExtras will be stable.

Any other suggestions/approaches, please do not hesitate to answer to my question above.

Update 2016-10-12

There is another stackoverflow question as well:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download