我有一个主模块和一些子模块.我想在它们之间指定一些不平凡的路由.
我更喜欢在子模块中定义子模块的路径.例如:
@NgModule({
imports: [
/*...*/
RouterModule.forChild([
{ path: 'country', redirectTo: 'country/list' },
{ path: 'country/list', component: CountryListComponent },
{ path: 'country/create', component: CountryCreateComponent },
/*...*/
])
],
declarations: [/*...*/],
exports: [
RouterModule,
],
})
export class CountryModule {}
Run Code Online (Sandbox Code Playgroud)
我想用自己的内部路由导入这个模块,但我想让它的整个路由前缀.
const appRoutes = [
{ path: '', component: HomeComponent },
/*... (basic routes)*/
];
@NgModule({
imports: [
/*...*/
RouterModule.forRoot(appRoutes),
CountryModule, // <- how to make its routing prefixed??
],
declarations: [
/*...*/
AppComponent,
],
bootstrap: [ AppComponent ]
})
export …Run Code Online (Sandbox Code Playgroud)