angularangular-router-loader

How to loadChildren async with angular-router-loader


I have folder structure like:

 - app
   -core
   -vacancy

in core folder I have app.routing.ts where I would like to async add route to vacancy.

I did it like:

export const routing = RouterModule.forRoot([
        {
            path: '',
            component: HomeComponent,
            canActivate: [AuthGuard]
        },
        {
            path: 'vacancy',
            loadChildren: '../vacancy#VacancyModule'
        },
        {
            path: '**',
            component: NotFoundComponent
        }
    ], {useHash: true}
);

i get an error:

Can't resolve '..\vacancy'

dispite the fact there is folder vacancy in folder app and inside of vacancy there is a file vacancy.module.ts which ` looks like:

// some imports here
@NgModule({
    declarations: [
        VacancyBaseComponent
    ],
    imports: [
        CommonModule,
        FormsModule,
        RouterModule.forChild(routes),
    ],
})

export class VacancyModule {
    public static routes = routes;
}

Any ideas what I'm doing wrong?


Solution

  • Bit late. In case you haven't figured it out, try this:

    loadChildren: 'app/vacancy/vacancy.module#VacancyModule'