在运行时的某个时刻,我的网址看起来像
http://localhost:4200/personal/51c50594-a95c-4a18-ac7b-b0521d67af96
我想转到一个只有不同 GUID
和不同内容的页面。
http://localhost:4200/personal/{otherGuid}
这是行不通的:
this.router.navigate(['/personal',new_ guid]);
如何在 Angular 2 中实现这一点?
最佳答案
试试下面,
....
this.router.navigate(['personal', id]);
....
constructor(route: ActivatedRoute, router: Router){
this.route.params.subscribe(param => {
// this will be fired when you change the guid,
// use the new param to reload component..
})
}
检查这个Plunker !!
关于javascript - 如何在 Angular 2 中重新加载组件的内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45921198/