我已经在我的应用程序中实现了延迟加载的模块,昨天我添加了HTTPIntercepter,并且路由停止工作。
我试图遵循所有可能的解决方案,但是在首次加载应用程序时会给出错误消息
vendor.js:75314 ERROR Error: Uncaught (in promise): Error: Cannot find module './login/login.module'
Error: Cannot find module './login/login.module'
我也关注了此页面,但这无助于解决我的问题 https://dev.to/devakone/angular-when-httpinterceptor-doesn-t-work-with-lazy-loaded-modules-3ipg
app-routing.module.ts
import { NgModule } from "@angular/core";
import { RouterModule, Routes } from "@angular/router";
import { AdminLayoutComponent } from "./templates/admin-layout/admin-layout.component";
import { AuthLayoutComponent } from "./templates/auth-layout/auth-layout.component";
const routes: Routes = [
{
path: "",
component: AdminLayoutComponent,
children: [
{
path: "admin",
loadChildren:
"./view/administrator/administrator.module#adminstratorModule"
},
{
path: "superadmin",
loadChildren: "./view/superadmin/superadmin.module#superadminModule"
},
]
},
{
path: "",
component: AuthLayoutComponent,
children: [
{ path: "login", loadChildren: "./login/login.module#LoginModule" }
]
}
];
@NgModule({
imports: [
RouterModule.forRoot(routes, { scrollPositionRestoration: "enabled" })
],
exports: [RouterModule]
})
export class AppRoutingModule {}
app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { HeaderComponent } from './shared/header/header.component';
import { RouterModule } from '@angular/router';
import { AppRoutingModule } from './app-routing.module';
import { SuperadminDashboardComponent } from './view/dashboards/superadmin-dashboard/superadmin-dashboard.component';
import { AdminDashboardComponent } from './view/dashboards/admin-dashboard/admin-dashboard.component';
import { ProviderDashboardComponent } from './view/dashboards/provider-dashboard/provider-dashboard.component';
import { ClientDashboardComponent } from './view/dashboards/client-dashboard/client-dashboard.component';
import { SidebarComponent } from './shared/sidebar/sidebar.component';
import { VaccineInventoryListComponent } from './view/immunizations/vaccine-inventory/vaccine-inventory-list/vaccine-inventory-list.component';
import { ImmunizationAlertsListComponent } from './view/immunizations/immunization-alerts/immunization-alerts-list/immunization-alerts-list.component';
import { ImmunizationRecordsListComponent } from './view/immunizations/immunization-records/immunization-records-list/immunization-records-list.component';
import { ProviderRolesComponent } from './view/provider/provider-roles/provider-roles.component';
import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
import { BroadcasterService } from 'ng-broadcaster';
import { CommonModule, DatePipe } from '@angular/common';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { ToastModule, ToastOptions } from 'ng6-toastr';
import { CustomToastrOption } from './shared/shared-component/custom-toastr-option';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { ChildrenSettingsComponent } from './view/children/children-settings/children-settings.component';
import { NgxSpinnerModule } from 'ngx-spinner';
import { SharedModule } from './shared/shared/shared.module';
import { NgDatepickerModule } from 'ng2-datepicker';
import { UserProfileComponent } from './view/user-profile/user-profile/user-profile.component';
import { UserProfileContactComponent } from './view/user-profile/user-profile-contact/user-profile-contact.component';
import { UserProfileGuardianComponent } from './view/user-profile/user-profile-guardian/user-profile-guardian.component';
import { UserProfileChildrenComponent } from './view/user-profile/user-profile-children/user-profile-children.component';
import { UserProfileSiblingsComponent } from './view/user-profile/user-profile-siblings/user-profile-siblings.component';
import { UserProfileChildrenCountComponent } from './view/user-profile/user-profile-children-count/user-profile-children-count.component';
import { UserProfileAppointmentsComponent } from './view/user-profile/user-profile-appointments/user-profile-appointments.component';
import { UserProfileVaccinesDueComponent } from './view/user-profile/user-profile-vaccines-due/user-profile-vaccines-due.component';
import { UserProfileClientCountComponent } from './view/user-profile/user-profile-client-count/user-profile-client-count.component';
import { UserProfileVaccinesAdministeredComponent } from './view/user-profile/user-profile-vaccines-administered/user-profile-vaccines-administered.component';
import { ChangepasswordComponent } from './view/changepassword/changepassword.component';
import { AngularDateTimePickerModule } from 'angular2-datetimepicker';
import { AngularGooglePlaceModule } from 'angular-google-place';
import { AuthLayoutComponent } from './templates/auth-layout/auth-layout.component';
import { AdminLayoutComponent } from './templates/admin-layout/admin-layout.component';
import { AgmCoreModule } from '@agm/core';
import { AdminProfileComponent } from './view/profile-page/admin-profile/admin-profile.component';
import { ClientProfileComponent } from './view/profile-page/client-profile/client-profile.component';
import { ProviderProfileComponent } from './view/profile-page/provider-profile/provider-profile.component';
import { SuperadminProfileComponent } from './view/profile-page/superadmin-profile/superadmin-profile.component';
import { childrenModule } from './view/children/children.module';
import { EncounterListComponent } from './view/children/encounter/encounter-list/encounter-list.component';
import { OwlDateTimeModule, OwlNativeDateTimeModule } from 'ng-pick-datetime';
import { VaccineSeriesComponent } from './view/immunizations/vaccine-series/vaccine-series.component';
import { InterceptService } from './shared/intercept.service';
import { LoginModule } from './login/login.module';
@NgModule({
declarations: [
HeaderComponent,
SuperadminDashboardComponent,
AdminDashboardComponent,
ProviderDashboardComponent,
ClientDashboardComponent,
SidebarComponent,
VaccineInventoryListComponent,
ImmunizationAlertsListComponent,
ImmunizationRecordsListComponent,
ProviderRolesComponent,
ChildrenSettingsComponent,
UserProfileComponent,
UserProfileContactComponent,
UserProfileGuardianComponent,
UserProfileChildrenComponent,
UserProfileSiblingsComponent,
UserProfileChildrenCountComponent,
UserProfileAppointmentsComponent,
UserProfileVaccinesDueComponent,
UserProfileClientCountComponent,
UserProfileVaccinesAdministeredComponent,
ChangepasswordComponent,
AuthLayoutComponent,
AdminLayoutComponent,
AdminProfileComponent,
ClientProfileComponent,
ProviderProfileComponent,
SuperadminProfileComponent,
EncounterListComponent,
VaccineSeriesComponent,
AppComponent,
],
imports: [
AgmCoreModule.forRoot({
apiKey: '[API Key redacted]'
}),
BrowserAnimationsModule,
BrowserModule,
FormsModule,
ReactiveFormsModule,
AppRoutingModule,
OwlDateTimeModule,
OwlNativeDateTimeModule,
CommonModule,
ToastModule.forRoot(),
RouterModule,
NgxSpinnerModule,
NgDatepickerModule,
SharedModule,
AngularDateTimePickerModule,
AngularGooglePlaceModule,
childrenModule,
LoginModule,
HttpClientModule
],
providers: [BroadcasterService, {
provide: ToastOptions, useClass: CustomToastrOption},
{provide:HTTP_INTERCEPTORS ,useClass: InterceptService,multi:true},
,DatePipe],
bootstrap: [AppComponent]
})
export class AppModule { }