Multiple modules and routing in angular 5

后端 未结 2 1568
一向
一向 2020-12-25 14:16

can somebody tell me how correct to set up routing when using multiple modules in my project? I have app.module and courses.module with some components declared in. I want t

2条回答
  •  甜味超标
    2020-12-25 15:04

    app.routing.module.ts

    const routes: Routes = [
      {
        path: '',
        children: [
          { path: 'courses', loadChildren: './components/courses/courses-routing.module#CoursesRoutingModule' }
        ]
      }
    ];
    

    courses.routing.module.ts

    const routes: Routes = [
      {
        path: '',
        children: [
          { path: 'list', component: CoursesListComponent}
        }
      }
    ];
    

    I would do it this way. Give it a try yourself and see how it goes.

提交回复
热议问题