How to change only params of route in angular2?
我在组件上有一个方法
现在,我想添加一个新模型,为此,需要将路线更改为:
1 2 3 | add(){ this.route.navigate(['model','0']); } |
I need to do this with the 'model' route dynamically, because the
route can change, it's possible ?
在你的构造函数中导入
1 2 3 4 | construction(private route: ActivatedRoute, ...) {} add() { this.router.navigate(['../', '0'], {relativeTo: this.route}); } |
你可以这样做
1 | this.router.navigate(['/model', 0]); |
更多信息请参考这里
试试这个
1 | this.route.navigate(['model/0']); |