Angular 2:如何与路由器建立相对链接?

时间:2016-08-08 01:54:24

标签: angular angular2-routing

如果我的路线看起来像这样:

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

是否可以创建仅在MyComponent内更新该网址的一部分的链接?例如,而不是:

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

我想使用类似的东西:

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

即,让组件只更新URL的一部分,而不必了解其余部分。

0 个答案:

没有答案