私は角4のWebアプリケーションを構築しています。トップレベルのルーティングモジュールと、各サブモジュール(ホームモジュールなど)ごとに別々のルーティングモジュールがあります。角4 - ルーティングのサブモジュールを解決できませんでした
これは私のトップレベルのルーティング設定である:
export const ROUTES: Routes = [
{path: '', loadChildren: './home#HomeModule'},
{path: '**', component: NotFoundComponent},
];
私はng server
を実行すると、私は奇妙なエラーを取得し、そのモジュールhome
が見つかりませんでした。アプリはブラウザでは動作しません。
奇妙な部分は次のとおりです。ファイルが変更され、webpackがプロジェクトを再コンパイルすると、すべてうまく動作し、ルーティングが機能します。
エラーはng serve
を実行しているときにのみ表示されます。事前に
ERROR in Error: Could not resolve module ./home relative to /path/to/my/project/src/app/app.module.ts
at StaticSymbolResolver.getSymbolByModule (/path/to/my/project/node_modules/@angular/compiler/bundles/compiler.umd.js:31884:30)
at StaticReflector.resolveExternalReference (/path/to/my/project/node_modules/@angular/compiler/bundles/compiler.umd.js:30350:62)
at parseLazyRoute (/path/to/my/project/node_modules/@angular/compiler/bundles/compiler.umd.js:28616:55)
at listLazyRoutes (/path/to/my/project/node_modules/@angular/compiler/bundles/compiler.umd.js:28578:36)
at visitLazyRoute (/path/to/my/project/node_modules/@angular/compiler/bundles/compiler.umd.js:29995:47)
at AotCompiler.listLazyRoutes (/path/to/my/project/node_modules/@angular/compiler/bundles/compiler.umd.js:29963:20)
at AngularCompilerProgram.listLazyRoutes (/path/to/my/project/node_modules/@angular/compiler-cli/src/transformers/program.js:157:30)
at Function.NgTools_InternalApi_NG_2.listLazyRoutes (/path/to/my/project/node_modules/@angular/compiler-cli/src/ngtools_api.js:44:36)
at AngularCompilerPlugin._getLazyRoutesFromNgtools (/path/to/my/project/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:247:66)
at Promise.resolve.then.then (/path/to/my/project/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:538:50)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
ありがとう:
この
は、私はプロジェクトがあるため、ファイルの変更を再コンパイルされていないng serve
を、実行しているとき、私が取得エラーです。
[レイジーローディングルート設定](https://angular.io/guide/router#lazy-loading-route-configuration)を知るのが大好きだ:*アドレスですAdminModuleファイルの場所(**アプリケーションルート**からの相対パス)、その後に#区切り記号、エクスポートされたモジュールクラスAdminModuleの名前* –