次のような遅延読み込みルートを使用して、Angular 2 / Angular Universal アプリを作成しました。
{
path: 'home',
loadChildren: './+app/+home/home.module#HomeModule'
},
{
path: '',
redirectTo: '/home',
pathMatch: 'full'
}
ブラウザでに移動するlocalhost
と、リダイレクトされ/home
、すべてが正常に機能します。localhost/home
しかし、ハード リロードでブラウザーに入るたびに、Node.js ターミナルでエラーがスローされます。
EXCEPTION: Uncaught (in promise): ReferenceError: System is not defined
ReferenceError: System is not defined at
SystemJsNgModuleLoader.loadAndCompile (...@angular/core/bundles/core.umd.js:7151:20)
ただし、ビューを正しくレンダリングしているようです。
非遅延ロードの方法を使用するようにルートを変更すると、エラーはなくなります。
{
path: 'home',
component: HomeComponent
}
しかし、アプリで遅延読み込みを使用したいと考えています。私の HTML では、SystemJS を使用してクライアント アプリをインポートします。
<script>
System.import('./client.js')
.then(function(m) {
console.log("Welcome");
});
</script>
私の依存関係:
"@angular/common": "2.1.2",
"@angular/compiler": "2.1.2",
"@angular/core": "2.1.2",
"@angular/forms": "2.1.2",
"@angular/http": "2.1.2",
"@angular/platform-browser": "2.1.2",
"@angular/platform-browser-dynamic": "2.1.2",
"@angular/router": "3.1.2",
"@angularclass/bootloader": "1.0.1",
"angular2-express-engine": "2.1.0-rc.1",
"angular2-template-loader": "0.6.0",
"angular2-universal": "2.1.0-rc.1",
"angular2-universal-polyfills": "2.1.0-rc.1"
この問題を解決するにはどうすればよいですか?