默认导航到子路径角度>>

问题描述 投票:0回答:1

我默认尝试导航到子路线,所以这是我的路线:

const routes: Routes = [
  {
    path: '', --> /config
    redirectTo: 'branding',
    component: ConfigurationComponent,
    children: [
      { path: 'branding', component: BrandingComponent },
      { path: 'channel-branding', component: ChannelBrandingComponent },
      { path: 'date-time', component: DateTimeSettingsComponent },
      { path: 'graph', component: GraphSettingsComponent },
      { path: 'grid', component: GridSettingsComponent },
      { path: 'labels', component: LabelSettingsComponent }
    ]
  },
];

父路线为/config,子路线为/config/branding,以此类推,如果有人导航到/config/branding,则默认情况下我想转到/config。我尝试使用redirectTo,但这似乎破坏了所有东西。如何获得这种行为?

我默认尝试导航到子路由,所以这是我的路由:const路由:Routes = [{path:``,-> / config redirectTo:'branding',component:ConfigurationComponent,...] >

angular
1个回答
0
投票

像这样在您的子数组中添加重定向

© www.soinside.com 2019 - 2024. All rights reserved.