[英]Redirect with extra parameters in URL
我在我的app-routing.module.ts中定義了路由
const routes: Routes = [
.
.
.
{ path: 'home', component: HomeComponent, canActivate: [AuthGuard] }
];
現在在我的一個組件中,根據條件,我想重定向到HomeComponent並在URL中傳遞額外的參數,例如/ home?redirect = 1
if( condition ) {
this.router.navigate(['/home?redirect=1'] );
} else {
this.router.navigate(['/home'] );
}
但是,它不起作用。 能否請您指教。
您應該添加如下參數:
let params: { 'redirect': 1}
this.router.navigate(['/home'], {queryParams: params})
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.