我正在使用 Angular 2hashlocation
战略。
该组件通过该路由加载:
"departments/:id/employees"
到目前为止还好。
在成功批量保存多个已编辑的表行后,我想通过以下方式重新加载当前路由 URL:
this.router.navigate([`departments/${this.id}/employees`]);
但什么也没发生,为什么呢?
在控制器中创建一个重定向到预期路由的函数,如下所示:
redirectTo(uri: string) {
this.router.navigateByUrl('/', { skipLocationChange: true }).then(() => {
this.router.navigate([uri]));
}
}
然后像这样使用它
this.redirectTo('//place your uri here');
该功能将重定向到虚拟路由并在用户没有意识到的情况下快速返回到目标路由。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)