Jhipster角2延迟加载模块未发现异常

时间:2022-01-03 20:33:19

I created the Jhipster application and try to add the lazy loading module, which give the module not found exception.

我创建了Jhipster应用程序并尝试添加延迟加载模块,这将使模块没有找到异常。

I follow the "https://jaseb.github.io/angular2-example/" article but still the same exception. I try myself. Please help me us to proceed further.Please find the code snippets as follows.

app.route.ts

    import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import {NavbarComponent} from "./layouts/navbar/navbar.component";

export const routes: Routes = [
    { path: '', component: NavbarComponent, outlet: 'navbar'},
    { path: 'lazy', loadChildren: 'app/modules/lazy/lazy.module#LazyModule' }
];

@NgModule({
    imports: [ RouterModule.forRoot(routes) ],
    exports: [ RouterModule ]
})
export class AppRoutingModule {
}

1 个解决方案

#1


1  

First you must install webpack plugin angular-router-loader

首先,必须安装webpack插件angular-router-loader

npm install angular-router-loader --save-dev

then in your project directory open webpack/webpack.common.js and add angular-router-loader after awesome-typescript-loader like below

然后在您的项目目录中打开webpack/webpack.common.js,并在awesome-typescript-loader之后添加angular-router-loader,如下所示

loaders: [
'angular2-template-loader',
'awesome-typescript-loader',
'angular-router-loader' // here
]

path should be without app prefix

path应该没有app前缀。

{ path: 'lazy', loadChildren: './modules/lazy/lazy.module#LazyModule' }

#1


1  

First you must install webpack plugin angular-router-loader

首先,必须安装webpack插件angular-router-loader

npm install angular-router-loader --save-dev

then in your project directory open webpack/webpack.common.js and add angular-router-loader after awesome-typescript-loader like below

然后在您的项目目录中打开webpack/webpack.common.js,并在awesome-typescript-loader之后添加angular-router-loader,如下所示

loaders: [
'angular2-template-loader',
'awesome-typescript-loader',
'angular-router-loader' // here
]

path should be without app prefix

path应该没有app前缀。

{ path: 'lazy', loadChildren: './modules/lazy/lazy.module#LazyModule' }