I want to define web site language on url. Such as "mysite.com/en/blabla". But I have different languages for each customer. And If customer does not support english, angular should return 404 and I try this:
const languages:Routes = Object.getOwnPropertyNames(environment.trader.langList).map(path => {
return {
path, component: OutComponent,
children: [
{ path: 'place-bet', loadChildren: '../../desktop/placebet/placebet.module#PlacebetModule' },
{ path: 'games', loadChildren: '../../desktop/games/games.module#GamesModule' },
{ path: 'dashboard', loadChildren: '../../desktop/dashboard/dashboard.module#DashboardModule' }]
};
})
debugger;
const OutRoutes: Routes = [
...languages
];
export const OutRouter = RouterModule.forChild(OutRoutes);
I get languages from environment and generate routes for each language. This works for run time but when I compile, it gives an error : "ERROR in Cannot read property 'loadChildren' of undefined". It can't compile mapped routes on compile time. How can I resolve it?