繁体   English   中英

角度路由回相同的 URL

[英]Angular routing back to same URL

嗨,我在 URL http://localhost:4200/dsc-ui/message中,现在用例是我应该能够通过在地址栏中手动键入路由来导航到特定的 url。 所以我需要将它导航到http://localhost:4200/dsc-ui/application-management ,所以当我在地址栏中键入 url http://localhost:4200/dsc-ui/application-management时,它会重新加载回http://localhost:4200/dsc-ui/message不知道为什么

所以在消息组件中,我正在检查 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']);
        } */
      }
    });

但我什至没有得到这个控制台,它只是重新加载回 /message。 在这方面需要帮助

路由通常在 RoutingModule 中完成。 在不了解您的 RoutingModule 的情况下,我们无法帮助您。 如果你没有设置自定义模块,它应该被称为 app-routing.module.ts

您可以在这里阅读更多关于如何使用 Angular Router 的信息: https ://angular.io/guide/router

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM