Angular2 Routing: import submodule with routing + making it prefixed

前端 未结 2 956
我寻月下人不归
我寻月下人不归 2020-12-18 03:56

I have a main module and some submodules. And I want to specify some not trivial routing between them.

I\'d prefer defining the routes of a submodule within the sub

2条回答
  •  醉酒成梦
    2020-12-18 04:52

    in your appRoutes add child route like

    const appRoutes = [
        { path: '', component: HomeComponent },
        {
        path: 'settings',
        component: CountryComponent,
        canActivate: [AuthGuard],
        children: COUNTRY_ROUTES
      },
    ];
    

    Create a separate routes file

    export const COUNTRY_ROUTES:Routes = [
      { path: 'country', redirectTo: 'country/list' },
      { path: 'country/list', component: CountryListComponent },
      { path: 'country/create', component: CountryCreateComponent },
    
    ];
    

    In CountryComponent.html

    
    

提交回复
热议问题