我正在使用以下代码将loadChildren用于登录模块,但显示错误“ ERROR错误:
“未捕获(承诺):错误:找不到模块 './login/login.module'“
{
path: 'login',
loadChildren: './login/login.module#LoginModule'
},
用于登录的组件模块是:
import { ModuleWithProviders, NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { LoginComponent } from './login.component';
import { LoginRoutingModule } from './login-routing.module';
@NgModule({
imports: [
LoginRoutingModule
],
declarations: [
LoginComponent
]
})
export class LoginModule {}
login-routing.module.ts
import { RouterModule, Routes } from '@angular/router';
import { LoginComponent } from './login.component';
const routes: Routes = [
{
path: '',
component: LoginComponent,
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class LoginRoutingModule {}
-
答案 0 :(得分:1)
从src到模块的路径应该是绝对路径。
loadChildren: 'src/app/login/login.module#LoginModule'