[英]Angular routing back to same URL
Hi I'm in the URL http://localhost:4200/dsc-ui/message
, now usecase is I should be able to navigate to particular url by typing route manually in the address bar.嗨,我在 URL http://localhost:4200/dsc-ui/message
中,现在用例是我应该能够通过在地址栏中手动键入路由来导航到特定的 url。 So I need to navigate it to http://localhost:4200/dsc-ui/application-management
, so when I type url http://localhost:4200/dsc-ui/application-management
in address bar it reloads back to http://localhost:4200/dsc-ui/message
not sure why所以我需要将它导航到http://localhost:4200/dsc-ui/application-management
,所以当我在地址栏中键入 url http://localhost:4200/dsc-ui/application-management
时,它会重新加载回http://localhost:4200/dsc-ui/message
不知道为什么
So in message component I'm checking for /application-management in ngonInit所以在消息组件中,我正在检查 ngonInit 中的 /application-management
this.router.events.subscribe((event: NavigationStart | null) => {
if (event instanceof NavigationStart) {
console.log('event', event.url);
/* if (event.url === '/application-management') {
this.router.navigate(['/application-management']);
} */
}
});
But I'm not even getting this console, it simply reloads back to /message.但我什至没有得到这个控制台,它只是重新加载回 /message。 Need an help on this在这方面需要帮助
Routing is usually done in a RoutingModule.路由通常在 RoutingModule 中完成。 Without knowing your RoutingModule, we cannot help you.在不了解您的 RoutingModule 的情况下,我们无法帮助您。 If you did not setup custom Modules, it should be called app-routing.module.ts如果你没有设置自定义模块,它应该被称为 app-routing.module.ts
Here you can read more about how to use Angular Router: https://angular.io/guide/router您可以在这里阅读更多关于如何使用 Angular Router 的信息: https ://angular.io/guide/router
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.