简体   繁体   English

router.navigate在Angular中不起作用

[英]router.navigate is not working in Angular

bellow is my redirect method which is not working 波纹管是我的重定向方法不起作用

    goToProdPage() {
       this.router.navigate([this.quoteId,'/cpq']);
       window.location.reload();
    }

but if i change this to 但是如果我将其更改为

goToProdPage() {
     this.router.navigate(['./'+this.quoteId+'/cpq']);
     window.location.reload();
}

Then its working fine. 然后它的工作正常。 but now i'm not able to get url param(which is quoteId) from activatedRoute in other components. 但是现在我无法从其他组件中的activatedRoute获取URL参数(这是quoteId)。

bellow is routing code in app.module.ts 下面是app.module.ts中的路由代码

const appRouter :Routes = [
   {path:'login', component: loginPage},
   {path:':quoteId/cpq', component: cpqPage},
   {path:'', redirectTo:'/login', pathMatch:'full'},
]

You don´t need window.location.reload(); 您不需要window.location.reload(); which will skip the cache and reload the same page, change it as 这将跳过缓存并重新加载同一页面,将其更改为

goToProdPage() {
    this.router.navigate([this.quoteId, 'cpq']);   
}

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

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