2

If I've got a route that looks like this:

{ path: 'my-component/:foo/:bar', component: MyComponent }

Is it possible to create a link that just updates one portion of that URL from within MyComponent? For example, instead of:

goToNextBar() {
   this.router.navigate(['/my-component/', this.foo, this.bar + 1]);
}

I'd like to use something like:

goToNextBar() {
    this.router.navigateToRelativeLink({ bar: this.bar + 1 });
}

ie, letting the component update just one portion of the URL without having to be aware of the rest.

David Wolever
  • 148,955
  • 89
  • 346
  • 502
  • I think you need to pass all parameters if they are all from one route. If one parameter is from a parent, then you don't need to pass that. You can use what is explained int the question linked to by Harry. – Günter Zöchbauer Aug 08 '16 at 06:55

0 Answers0