我正在开发一个简单的网页,它有一个主页模块,其中包含两个组件,主页和登录,我使用延迟加载加载...
这是我的应用路由模块
const routes: Routes = [
{ path: '', redirectTo: 'home', pathMatch: 'full' },
{ path: 'home', loadChildren: 'app/home/home.module#HomeModule' },
{ path: 'main', loadChildren: 'app/main/main.module#MainModule' }
];
@NgModule({
imports: [
HomeRoutingModule,
RouterModule.forRoot(routes)
],
exports: [RouterModule],
providers: []
})
export class GESFWRoutingModule { }
这是我的家庭模块...
const routes = [
{ path: 'home', component: HomeComponent },
{ path: 'login', component: LoginComponent }
]
@NgModule({
imports: [
CommonModule,
RouterModule.forChild(routes),
ReactiveFormsModule
],
declarations: [
HomeComponent,
LoginComponent
],
providers: [
AuthService
]
})
export class HomeModule { }
正如预期的那样,这部分工作得很好。我遇到的问题是当我转到主模块时......我正在尝试延迟加载我的客户端模块
const routes: Routes = [
{ path: '', redirectTo: 'main', pathMatch: 'full', children: [
{ path: 'clientes', loadChildren: 'app/clientes/clientes.module#ClientesModule' }
]},
];
@NgModule({
imports: [
CommonModule,
MainRoutingModule,
RouterModule.forChild(routes)
],
declarations: [
MainComponent,
HeaderComponent,
],
})
export class MainModule { }
有了这里的客户模块...
const routes: Routes = [
{ path: '', component: ClientesComponent }
];
@NgModule({
imports: [
CommonModule,
RouterModule.forChild(routes)
],
declarations: [
ClientesComponent,
ClientesOperacoesComponent,
SearchTableComponent
],
providers: [
MainService
]
})
export class ClientesModule { }
一切正常,直到我尝试访问'/main/clientes'。它说它无法匹配任何路线:'main/clientes'。现在我尝试了多种方法来解决这个问题,但总是同样的问题,如果你能在我的逻辑中发现任何错误,我将非常感激。
谢谢!