2

I have a route like below

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',
  },
];

I have two directories which have dashboard module, say 'core' and 'temp'. I want to check if dashboard module exist in 'temp' then the route should be './core/temp/dashboard.module#DashboardModule' else './core/dashboard/dashboard.module#DashboardModule'

Is this possible?

laiju
  • 1,353
  • 10
  • 17
  • 2
    You should take a look at CanActivateGuard. Or maybe this helps: https://stackoverflow.com/questions/34660263/angular2-conditional-routing – seven Nov 30 '17 at 07:00
  • is there a way to check whether a module exist in a directory? – laiju Nov 30 '17 at 07:14

1 Answers1

0

If your module does not exist in your Directory, you wont be able to import it to your routing module.

seven
  • 414
  • 4
  • 12