Angular lazy load子模块空白路径重定向到appModule

Cod*_*ver 2 angular2-routing angular

我正在研究Angular 6项目.自从过去几天我遇到了以下问题.请指导.

我的程序基于延迟路由,也有动态路由.以下代码是我的app-routing.module.ts:

 const routes: Routes = [
      {
        path: 'login',
        loadChildren: './login/login.module#LoginModule'
      },
     // Here is my submodule 
      {
        path: '',
        loadChildren: './users/users.module#UsersModule'
      },
     // This is actually i want use to home page as blank 
      {
        path: '',
        loadChildren: './home/home.module#HomeModule'
      },
      { path: '**', redirectTo: 'not-found' }
    ];
@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
Run Code Online (Sandbox Code Playgroud)

以下是我的内部/子模块:

  const routes: Routes = [
    {
    path: '',
     component: UsersComponent,
    children: [
        // How can redirect to the main route
    { path: '', redirectTo: '', pathMatch: 'full' },
    { path: ':slug', loadChildren: './inner1/inner1.module#Inner1Module' },
    { path: ':slug/:slug2', loadChildren: './inner2/inner2.module#Inner2Module' }
    ]
    }];
    @NgModule({
    imports: [RouterModule.forChild(routes)],
    exports: [RouterModule]
    })
Run Code Online (Sandbox Code Playgroud)

我有两个不同的模板用于主路由器插座和内部路由器插座.这就是我想将路径从内部/子模块重定向到主模块的原因.提前致谢.

Kes*_*ran 7

您的userModule路线规则应如下所示.检查如何在下面的链接中构建延迟加载的模块

export const RouteConfig: Routes = [
    {
        path: '',
        component: UsersComponent,
        canActivate: [AuthGuard],
        children: [
               { path: '', component: UserPage , children: [
               { path: ':slug', component: 'Inner1Component' },
               { path: ':slug/:slug2', component: 'Inner2Component' }]
        ]
    }
];
Run Code Online (Sandbox Code Playgroud)