我有.NET Core + Angular 2 / Typescript / SystemJS应用程序。并使用延迟加载来加载模块
这是 app-routing.module.ts :
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
const routes: Routes = [
{ path: '', loadChildren: 'app/dashboard/dashboard.module#DashboardModule' },
{ path: 'signup', loadChildren: 'app/signup/signup.module#SignUpModule' },
{ path: 'signin', loadChildren: 'app/signin/signin.module#SignInModule' },
{ path: 'welcome', loadChildren: 'app/welcome/welcome.module#WelcomeModule' },
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
welcome-routing.module.ts :
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { AuthGuard } from './../providers/auth-guard.service';
import { WelcomeComponent } from './welcome.component';
const welcomeRoutes: Routes = [
{ path: '', component: WelcomeComponent, canActivate: [AuthGuard] }
];
@NgModule({
imports: [RouterModule.forChild(welcomeRoutes)],
exports: [RouterModule]
})
export class WelcomeRoutingModule { }
因此,当我登录并转到信息中心页面http://example.com/时。然后在Web应用程序上没有活动大约1-2分钟,然后单击欢迎页面我有时会出错(有时页面加载正确):
zone.min.js:1 GET http://example.com/app/welcome/welcome.module.js 500 (Internal Server Error)
core.umd.min.js:13 ERROR Error: Uncaught (in promise): Error: (SystemJS) XHR error (500 Internal Server Error) loading http://example.com/app/welcome/welcome.module.js
Error: XHR error (500 Internal Server Error) loading http://example.com/app/welcome/welcome.module.js
当我插入浏览器网址http://example.com/app/welcome/welcome.module.js
时我在控制台中有错误:
Failed to load resource: the server responded with a status of 500 (Internal Server Error)
点击“硬重装”后一切正常。服务器端似乎正常工作。我无法理解错误的原因。
延迟加载? SystemJS错误地加载模块?还是其他什么? 我该如何解决这个随机问题?