gpt4 book ai didi

angular - 错误错误 : StaticInjectorError Angular 6

转载 作者:太空狗 更新时间:2023-10-29 17:45:03 26 4
gpt4 key购买 nike

从 Angular 5 迁移到 6 后,我遇到了静态注入(inject)器的问题。错误是:

ERROR Error: StaticInjectorError(AppModule)[StorageService -> LocalStorageService]: StaticInjectorError(Platform: core)[StorageService -> LocalStorageService]: NullInjectorError: No provider for LocalStorageService! at NullInjector.push../node_modules/@angular/core/fesm5/core.js.NullInjector.get (core.js:1062) at resolveToken (core.js:1300) at tryResolveToken (core.js:1244) at StaticInjector.push../node_modules/@angular/core/fesm5/core.js.StaticInjector.get (core.js:1141) at resolveToken (core.js:1300) at tryResolveToken (core.js:1244) at StaticInjector.push../node_modules/@angular/core/fesm5/core.js.StaticInjector.get (core.js:1141) at resolveNgModuleDep (core.js:8376) at _createClass (core.js:8423) at _createProviderInstance (core.js:8393) at resolveNgModuleDep (core.js:8356) at _createClass (core.js:8423) at createProviderInstance (core.js:8393) at resolveNgModuleDep (core.js:8356) at NgModuleRef.push../node_modules/@angular/core/fesm5/core.js.NgModuleRef_.get (core.js:9064) at resolveDep (core.js:9429) at createClass (core.js:9309) at createDirectiveInstance (core.js:9186) at createViewNodes (core.js:10406) at createRootView (core.js:10320) at callWithDebugContext (core.js:11351) at Object.debugCreateRootView [as createRootView] (core.js:10838) at ComponentFactory_.push../node_modules/@angular/core/fesm5/core.js.ComponentFactory_.create (core.js:8666) at ComponentFactoryBoundToModule.push../node_modules/@angular/core/fesm5/core.js.ComponentFactoryBoundToModule.create (core.js:3315) at ApplicationRef.push../node_modules/@angular/core/fesm5/core.js.ApplicationRef.bootstrap (core.js:4550) at core.js:4358 at Array.forEach () at PlatformRef.push../node_modules/@angular/core/fesm5/core.js.PlatformRef._moduleDoBootstrap (core.js:4358) at core.js:4324 at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:388) at Object.onInvoke (core.js:3824) at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:387) at Zone.push../node_modules/zone.js/dist/zone.js.Zone.run (zone.js:138) at zone.js:872 at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421) at Object.onInvokeTask (core.js:3815) at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:420) at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:188)

import { InfiniteScrollModule } from 'ngx-infinite-scroll';
import { AuthModule } from './auth/auth.module';
import { ConfigurationModule } from './configuration/configuration.module';
import { CoreModule } from './core/core.module';
import { SharedModule } from './shared/shared.module';
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppRoutingModule } from './app-routing.module';
import { HomeComponent } from './home/home.component';
import { AppComponent } from './app.component';
import { HttpModule } from '@angular/http'
import { HttpClientModule } from '@angular/common/http';



@NgModule({
declarations: [
AppComponent,
HomeComponent
],
imports: [
BrowserModule,
AppRoutingModule,
SharedModule,
CoreModule,
ConfigurationModule,
AuthModule,
InfiniteScrollModule,
HttpModule,
HttpClientModule


],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }

这是我的 app.module 文件。感谢您的帮助。

最佳答案

您需要在 module.ts 中的 providers 下添加 LocalStorageService

providers: [LocalStorageService ]

关于angular - 错误错误 : StaticInjectorError Angular 6,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52437033/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com