Friday, January 5, 2018

routes that point to modules instead of components

Assuming this as suggested here:

const myRoutes = [
   {path: '', component: StartingOutComponent},
   {path: 'foo', component: FooComponent},
   {path: 'bar', component: BarComponent}
];

 
 

The following change may allow for the loading of modules wrapping the components in the name of this trick:

const myRoutes = [
   {path: '', loadChildren: () => System.import('../startingOut.module')},
   {path: 'foo', loadChildren: () => System.import('../foo.module')},
   {path: 'bar', loadChildren: () => System.import('../bar.module')}
];

 
 

I have not tried this myself. This is how things seem to behave in an app I am looking at:

No comments:

Post a Comment