RangeError: Maximum call stack size exceeded Lazy routing Angular 2

后端 未结 7 856
礼貌的吻别
礼貌的吻别 2020-12-13 23:38

I\'m trying to implement lazy routing into my app.

I have a very big project and when it was at router-deprecated I used AsyncRoute, but now it was removed.

7条回答
  •  一整个雨季
    2020-12-14 00:09

    loadChildren needs to reference module with routing

    By assigning a value to loadChildren property inside a route, you have to reference a module, which has a routing system implemented. In other words reference only a module that imports RoutingModule and configures it with forChild(routes) method.

    import { NgModule } from '@angular/core';
    import { RouterModule, Routes } from '@angular/router';
    // import { CommonModule } from '@angular/common';
    /* ---------------  !System modules  --------------- */
    
    import { SharedModule } from 'sharedModule';   //There is  a lot of shared components/directives/pipes (over 60) and it re-exports CommonModule so I can't avoid it
    /* ---------------  !App outer modules  --------------- */
    
    
    import { EncountersComponent } from './encounters.component';
    // import { PassCodeComponent } from '../../shared/components/passcode/passcode.component';
    
    export const encountersModuleRoutes: Routes = [
      /* configure routes here */
    ];
    
    
    @NgModule({
      imports: [ SharedModule, RouterModule.forChild(encountersModuleRoutes) ],
      declarations: [ EncountersComponent],
      exports: [ EncountersComponent ],
    })
    
    
    export class EncountersModule {  }
    

提交回复
热议问题