Próbuję wprowadzić leniwy routing do mojej aplikacji.RangeError: Przekroczono maksymalny rozmiar stosu wywołań Lazy routing Angular 2
Mam bardzo duży projekt i kiedy był na routerze przestarzałe, użyłem AsyncRoute, ale teraz został usunięty.
Więc starałem się wdrożyć najnowszy leniwy załadunku, ale mam problem RangeError: Maksymalny rozmiar stosu wywołań przekroczyła Co robię źle? Zrobiłem wszystko, jak w instrukcjach.
Spójrz proszę
EncountersModule
import { NgModule } from '@angular/core';
// 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';
@NgModule({
imports: [ SharedModule ],
declarations: [ EncountersComponent],
exports: [ EncountersComponent ],
})
export class EncountersModule { }
Oto moja app.routing.module
import { NgModule } from '@angular/core';
// import { ModuleWithProviders } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { ImagingComponent } from '../modules/index';
import { DashboardComponent } from '../modules/index';
import { PrescriptionNoticesComponent } from '../modules/index';
// import { EncountersComponent } from "../modules/encounters/encounters.component";
import { ScheduleComponent } from "../modules/schedule/schedule.component";
import { AdminComponent } from '../modules/index';
@NgModule({
imports: [
RouterModule.forRoot([
{
path: '',
component: DashboardComponent,
data: { label: 'Dashboard' }
},
{
path: 'encounters',
// component: EncountersComponent,
loadChildren: 'production/modules/encounters/encounters.module#EncountersModule',
data: { label: 'Encounters' }
},
{
path: 'admin',
component: AdminComponent,
data: { label: 'Admin' }
}
])
],
exports: [
RouterModule
]
})
export class AppRoutingModule {}
// const appRoutes: Routes = [
// {
// path: 'imaging',
// component: ImagingComponent,
// data: { label: 'Imaging' }
// },
// {
// path: '',
// component: DashboardComponent,
// data: { label: 'Dashboard' }
// },
// {
// path: 'prescription_notices',
// component: PrescriptionNoticesComponent,
// data: { label: 'Prescription Notices' }
// },
// {
// path: 'encounters',
// component: EncountersComponent,
// data: { label: 'Encounters' }
// },
// {
// path: 'schedule',
// component: ScheduleComponent,
// data: { label: 'Schedule' }
// },
// {
// path: 'admin',
// component: AdminComponent,
// data: { label: 'Admin' }
// }
// ];
//
// export const appRoutingProviders: any[] = [
//
// ];
//
// export const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes);
prawdopodobnie dlatego, że nie mam żadnej trasy dla mojego encounters.module – Velidan
Ewentualnie spróbuj usunąć komentarze. Kiedy zaktualizowałem swój router do bieżącego w aplikacji, nad którą pracowałem, skomentowałem kilka rzeczy ze starego routera, ponieważ nie chciałem go zgubić. Po usunięciu komentarzy niektóre dziwne błędy zniknęły. Mimo, że wszystkie moje komentarze znajdowały się na górze mojego kodu, nie jestem pewien, czy to dotyczy. – Frank
Dzięki Frank za pomoc! – Velidan