在之前的路由器中 在路由器链接中我们只是将它用于子路由器
Sorter.sort(List<?> list)
但是现在我们创建一个模块,推送它为forchild
<a routerLink="/store/branches" routerLinkActive="active">Branches</a>
那我们怎么去RouterModule.forChild(routes)
?
因为我不断收到错误说
localhost/store/branches
这是我的store.routing.module
cannot set property of 'name' unknown
store.module
const routes: Routes = [
{ path: '', component: StoreComponent,
children: [
{ path: '', component: BranchesComponent },
{ path: 'branches', component: BranchesComponent },
{ path: 'report', component: ReportSalesByTenantComponent }
]
},
];
@NgModule({
imports: [ RouterModule.forChild(routes) ],
exports: [ RouterModule ]
})
export class storeRoutingModule {}
app.routing.module这是我的主要路由
@NgModule({
imports: [
CommonModule,
FormsModule,
storeRoutingModule
],
declarations: [
storeComponent,
BranchesComponent,
ReportSalesByTenantComponent
]
})
export class storeModule { }
这是我的模块
const routes: Routes = [
{ path: '', redirectTo: '/login', pathMatch: 'full' },
{ path: 'login', component: LoginComponent },
{ path: 'MainMenu', component: MenuComponent},
{
path: 'store',
loadChildren: 'app/MainMenu/store/store.module#storeModule',
},
];
@NgModule({
imports: [ RouterModule.forRoot(routes) ],
exports: [ RouterModule ]
})
export class AppRoutingModule {}