繁体   English   中英

如何将Angular路由重定向到同一路由+辅助路由? (来自路由器)

[英]How to redirect an Angular route to the same route + an auxiliary route? (From the router)

我对应用程序的一些看法使用辅助路径来显示侧边栏。 但是,我想确保如果用户决定直接输入url“/ dashboard / recipes”(主路径),他们将被重新路由到“/ dashboard / recipes(sidebar:recipe-list)”。

这是我的尝试:

const routes: Routes = [
  { path: '', component: DashboardComponent },
  { path: 'recipes', component: RecipesComponent, redirectTo:'/dashboard/properties(sidebar:property-list)' },
  { path: 'recipe-list', outlet: 'sidebar', component: RecipeListComponent }
];

这不起作用,可能是因为食谱路线不断重新路由。 但是我怎么能从路由器做到这一点? 或者唯一的方法是在解析url的组件中放入一些代码,检查辅助路由是否存在? (我想在路由器文件上有这个逻辑)。

暂无
暂无

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

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