Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular “在”时获取错误;ng serve“;无法读取属性';loadChildren';未定义的_Angular_Typescript_Angular Routing_Lazy Loading_Angular Load Children - Fatal编程技术网

Angular “在”时获取错误;ng serve“;无法读取属性';loadChildren';未定义的

Angular “在”时获取错误;ng serve“;无法读取属性';loadChildren';未定义的,angular,typescript,angular-routing,lazy-loading,angular-load-children,Angular,Typescript,Angular Routing,Lazy Loading,Angular Load Children,我正在做我的项目,我想延迟加载我的模块,它工作得很好,但当我“ng SERVICE”m代码时,我得到了这个错误 “无法读取未定义的属性'loadChildren'” 这是我的应用程序路由模块 export const appRoutes: Routes = [ { path: '', redirectTo: 'login', pathMatch: 'full', canActivate: [AuthGuard] }, { path: 'login',

我正在做我的项目,我想延迟加载我的模块,它工作得很好,但当我“ng SERVICE”m代码时,我得到了这个错误 “无法读取未定义的属性'loadChildren'”

这是我的应用程序路由模块

export const appRoutes: Routes = [
  {
    path: '',
    redirectTo: 'login',
    pathMatch: 'full',
    canActivate: [AuthGuard]
  },
  { path: 'login', component: LoginComponent },
  {
    path: 'corrrisk',
    component: WelcomeComponent,
    children: [
      { path: '', component: CorrriskHomeComponent, pathMatch: 'full' },
      {
        path: 'security',
        loadChildren: './modules/security/security.module#CorrSecurityModule' ,
        data: { preload: false }
      },
      {
        path: 'setup',
        loadChildren: './modules/setup/setup.module#CorrSetupModule',
        data: { preload: true }
      },
      {
        path: 'limit',
        loadChildren: './modules/limits/limits.module#CorrLimitModule'
      },
      {
        path: 'businesspolicy',
        loadChildren:
          './modules/businesspolicy/businesspolicy.module#CorrBusinessPolicyModule',
        data: { preload: false }
      }
    ]
  }
];
@NgModule({
  imports: [
    RouterModule.forRoot(appRoutes, {
      preloadingStrategy: SelectivePreloadingStrategy
    })
  ],
  exports: [RouterModule],
  providers: [SelectivePreloadingStrategy]
})
export class AppRoutingModule {}
@NgModule({
  declarations: [
    AppComponent,
    LoginComponent,
    WelcomeComponent,
    CorrriskHomeComponent,
   ],
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
    MatIconModule,
    DxAccordionModule,
    FormsModule,
    ReactiveFormsModule,
    HttpClientModule,
    AppRoutingModule,
    DevExtremeModule,
    CorrOperationsModule,
    CorrCommonModule,
    CorrMISModule,
    NgReduxModule
  ],
  providers: [
    httpInterceptorProviders,
    appStoreProviders,
    { provide: LOCALE_ID, useValue: 'en-US' }
  ],
  bootstrap: [AppComponent]
})
export class AppModule {
  constructor(
    ngRedux: NgRedux<any>,
    @Inject(AppStore) public store: Redux.Store<AppStateRedux>,
    overlayContainer: OverlayContainer
  ) {
    overlayContainer.getContainerElement().classList.add('unicorn-dark-theme');
    ngRedux.configureStore(rootReducer, {}, [thunk], []);
  }
}
这是我的应用程序模块代码

export const appRoutes: Routes = [
  {
    path: '',
    redirectTo: 'login',
    pathMatch: 'full',
    canActivate: [AuthGuard]
  },
  { path: 'login', component: LoginComponent },
  {
    path: 'corrrisk',
    component: WelcomeComponent,
    children: [
      { path: '', component: CorrriskHomeComponent, pathMatch: 'full' },
      {
        path: 'security',
        loadChildren: './modules/security/security.module#CorrSecurityModule' ,
        data: { preload: false }
      },
      {
        path: 'setup',
        loadChildren: './modules/setup/setup.module#CorrSetupModule',
        data: { preload: true }
      },
      {
        path: 'limit',
        loadChildren: './modules/limits/limits.module#CorrLimitModule'
      },
      {
        path: 'businesspolicy',
        loadChildren:
          './modules/businesspolicy/businesspolicy.module#CorrBusinessPolicyModule',
        data: { preload: false }
      }
    ]
  }
];
@NgModule({
  imports: [
    RouterModule.forRoot(appRoutes, {
      preloadingStrategy: SelectivePreloadingStrategy
    })
  ],
  exports: [RouterModule],
  providers: [SelectivePreloadingStrategy]
})
export class AppRoutingModule {}
@NgModule({
  declarations: [
    AppComponent,
    LoginComponent,
    WelcomeComponent,
    CorrriskHomeComponent,
   ],
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
    MatIconModule,
    DxAccordionModule,
    FormsModule,
    ReactiveFormsModule,
    HttpClientModule,
    AppRoutingModule,
    DevExtremeModule,
    CorrOperationsModule,
    CorrCommonModule,
    CorrMISModule,
    NgReduxModule
  ],
  providers: [
    httpInterceptorProviders,
    appStoreProviders,
    { provide: LOCALE_ID, useValue: 'en-US' }
  ],
  bootstrap: [AppComponent]
})
export class AppModule {
  constructor(
    ngRedux: NgRedux<any>,
    @Inject(AppStore) public store: Redux.Store<AppStateRedux>,
    overlayContainer: OverlayContainer
  ) {
    overlayContainer.getContainerElement().classList.add('unicorn-dark-theme');
    ngRedux.configureStore(rootReducer, {}, [thunk], []);
  }
}
@NgModule({
声明:[
应用组件,
LoginComponent,
欢迎光临,
CorriskHomeComponent,
],
进口:[
浏览器模块,
BrowserAnimationsModule,
Maticon模块,
DX手风琴模块,
FormsModule,
反应形式模块,
HttpClientModule,
批准模块,
devextreme模块,
腐蚀模块,
CorrCommonModule,
CorrMISModule,
Ngredux模块
],
供应商:[
httpInterceptorProviders,
appStoreProviders,
{提供:LOCALE_ID,useValue:'en-US'}
],
引导:[AppComponent]
})
导出类AppModule{
建造师(
ngRedux:ngRedux,
@Inject(AppStore)公共存储:Redux.store,
覆盖容器:覆盖容器
) {
overlyContainer.getContainerElement().classList.add('unicorn-dark-theme');
configureStore(rootReducer,{},[thunk],]);
}
}

当我在应用程序路由文件中放置空间时,它可以很好地编译。请告诉我上述代码中存在什么问题。

我能够通过使用AOT激活常春藤渲染器来修复错误:

您可以在angular.json中激活它

{
  "projects": {
    "my-existing-project": {
      "architect": {
        "build": {
          "options": {
            ...
            "aot": true,
          }
        }
      }
    }
  }
}
尝试执行生成(
ngbuild--prod--aot
),这会给您带来更具描述性的错误。