gpt4 book ai didi

javascript - 如何在 Angular 2 中重新加载组件的内容?

转载 作者:行者123 更新时间:2023-11-30 11:31:56 25 4
gpt4 key购买 nike

运行时的某个时刻,我的网址看起来像

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com