我有一个NullInjectorError问题,起初该应用程序可以运行,但是我已经复制了一个Module来制作两个相似的版本,编译时并没有给我错误,它仅在我使用Navigate转到它时才显示。原始模块有效,另一个模块显示了此错误:
我的项目结构:
|
|demeter-routing.module
|
|AdminPanel (folder)
|admin-panel.module.ts
|
|ClientPanel(folder)
|admin-panel.module.ts
模块代码:
ClientPanel:
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { AdminPanelRoutingModule } from './admin-panel-routing.module';
import { HttpClientModule, HttpClient } from '@angular/common/http';
import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
export function HttpLoaderFactory(http:HttpClient){
return new TranslateHttpLoader(http, './assets/languages/', '.json');
}
@NgModule({
declarations: [],
imports: [
CommonModule,
AdminPanelRoutingModule,
HttpClientModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: HttpLoaderFactory,
deps: [HttpClient]
}
}),
]
})
export class AdminPanelModule { }
管理窗格:
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { AdminPanelRoutingModule } from './admin-panel-routing.module';
import { HttpClientModule, HttpClient } from '@angular/common/http';
import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
export function HttpLoaderFactory(http:HttpClient){
return new TranslateHttpLoader(http, './assets/languages/', '.json');
}
@NgModule({
declarations: [],
imports: [
CommonModule,
AdminPanelRoutingModule,
HttpClientModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: HttpLoaderFactory,
deps: [HttpClient]
}
}),
]
})
export class AdminPanelModule { }
demeter.module.ts:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppRoutingModule } from './demeter-routing.module';
import { AppComponent } from './demeter.component';
import { LoginComponent } from './components/login/login.component';
import { CrearCuentaComponent } from './components/crear-cuenta/crear-cuenta.component';
//Traductor
import {TranslateHttpLoader} from "@ngx-translate/http-loader";
import {HttpClientModule, HttpClient, HTTP_INTERCEPTORS} from "@angular/common/http";
import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
export function HttpLoaderFactory(http:HttpClient){
return new TranslateHttpLoader(http, './assets/languages/', '.json');
}
//Ng-Module para bootstrap
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
//Ng module para formularaios y comunicación TS-HTML
import { FormsModule } from '@angular/forms';
import { PopoverComponent } from './components/popover/popover.component';
import { AlertComponent } from './components/alert/alert.component';
import { VarLogins } from './services/varLogins.service';
//Panel robado
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { CoreModule as CoreModule1} from './modules/AdminPanel/@core/core.module';
import { CoreModule as CoreModule2} from './modules/ClientPanel/@core/core.module';
import { ThemeModule as ThemeModule1} from './modules/ClientPanel/@theme/theme.module';
import { ThemeModule as ThemeModule2 } from './modules/AdminPanel/@theme/theme.module';
import {
NbChatModule,
NbDatepickerModule,
NbDialogModule,
NbMenuModule,
NbSidebarModule,
NbToastrModule,
NbWindowModule,
} from '@nebular/theme';
@NgModule({
declarations: [
AppComponent,
LoginComponent,
CrearCuentaComponent,
PopoverComponent,
AlertComponent
],
imports: [
FormsModule,
NgbModule,
BrowserModule,
AppRoutingModule,
//Importacion traducción
HttpClientModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: HttpLoaderFactory,
deps: [HttpClient]
}
}),
BrowserAnimationsModule,
CoreModule1.forRoot(),
ThemeModule1.forRoot(),
CoreModule2.forRoot(),
ThemeModule2.forRoot(),
NbSidebarModule.forRoot(),
NbMenuModule.forRoot(),
NbDatepickerModule.forRoot(),
NbDialogModule.forRoot(),
NbWindowModule.forRoot(),
NbToastrModule.forRoot(),
NbChatModule.forRoot({
messageGoogleMapKey: 'AIzaSyA_wNuCzia92MAmdLRzmqitRGvCF7wCZPY',
}),
],
bootstrap: [AppComponent],
providers:[VarLogins]
})
export class AppModule { }
我看到了导入import {HttpClientModule, HttpClient, HTTP_INTERCEPTORS} from "@ angular / common / http";
但是我已经有了它,我不知道还有什么