I am trying to load the routes from a JSON file, as i do not want to hard code them and load the routes lazily. Something like this:
import { RouterModule } from '@angular/router';
const routes = [
{ path: '', loadChildren: 'app/home/home.module' },
{ path: ':item/shoes', loadChildren: 'app/shoes/shoes.module' },
{ path: ':item/watch', loadChildren: 'app/watch/watch.module' }
];
export default RouterModule.forRoot(routes);
{ path: '', loadChildren: 'app/home/home.module' },
{ path: ':item/shoes', loadChildren: 'app/shoes/shoes.module' },
{ path: ':item/watch', loadChildren: 'app/watch/watch.module' }
I am reading the JSON file using a service which is injected in a component. How do i inject the service in the router to get the values? Or is there any other better way using which i can load the routes from JSON?