I'm converting to Standalone Components and as they suggest to convert the routes to that:
// In the main application:
export const ROUTES: Route[] = [
{path: 'admin', loadChildren: () => import('./admin/routes')},
// ...
];
// In admin/routes.ts:
export default [
{path: 'home', component: AdminHomeComponent},
{path: 'users', component: AdminUsersComponent},
// ...
] as Route[];
But in my current RoutingModule i provide the Routes dynamically using the ROUTES InjectionToken
.
providers: [
{
provide: ROUTES,
useFactory: (gfConfigService: GfConfigService): Routes => gfConfigService.createRoutes(),
deps: [GfConfigService],
multi: true,
},
],
Context: So the routes are not really dynamically, but the creation of the Routes depends on some data which is stored in the GfConfigService
.
Any idea's how to get rid of this RoutingModule, while still providing the automatic generated routes
and still load them lazy
when the router hit's for example /admin
?