如何使用UIRouter angular.io设置默认子状态

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

我如何通过ui-router和angular.io设置默认的子状态?我有一个关于子状态的部分。我想做的是,当我进入“关于”部分时,默认情况下它将呈现第一个子状态。

javascript html angular angular-ui-router
1个回答
0
投票

您可以像这样重定向默认的子路由:

{
path: 'course',
component: CourseComponent,
children: [
  {
    path: 'list',
    component: CourseListComponent
  },
  {
    path: 'taking',
    component: TakingCourseComponent
  },
  {
    path: '**',
    redirectTo: 'list',  // this work like as default custom route. 
    pathMatch: 'full'
  }
 ]
},
© www.soinside.com 2019 - 2024. All rights reserved.