Angular 4 Route基于条件

时间:2017-11-30 06:58:46

标签: angular

我有一条如下路线

export const AppRoutes: Routes = [
  {
    path: '',
    redirectTo: 'dashboard',
    pathMatch: 'full',
  },
  {
  path: '',
  component: LayoutComponent,
  canActivate: [ AuthGuard ],
  children: [
    {
      path: 'dashboard',
      loadChildren: './core/dashboard/dashboard.module#DashboardModule',
      canLoad: [AuthGuard]
    },
  ]},
  {
    path: 'login',
    loadChildren: coreRoute.login,
  },
  {
    path: '404',
    component: NotfoundComponent,
  },
  {
    path: '**',
    redirectTo: '404',
  },
];

我有两个带有仪表板模块的目录,比如“核心”和“#39;并且' temp'。我想检查仪表板模块是否存在于“临时”状态。那么路线应该是' ./core / temp / dashboard.module#DashboardModule' else' ./core / dashboard / dashboard.module#DashboardModule'

这可能吗?

1 个答案:

答案 0 :(得分:0)

如果目录中不存在您的模块,则无法将其导入路由模块。