Uncaught (in promise): Error: StaticInjectorError(AppModule)[options]

后端 未结 8 1710
借酒劲吻你
借酒劲吻你 2020-12-01 14:08

I have a strange error. Usually (I did my googling), in this case of errors Angular specifies in square brackets which exactly module/service/provider/etc caused the problem

8条回答
  •  没有蜡笔的小新
    2020-12-01 14:12

    I was having the same problem using my class SharedModule.

    export class SharedModule {
        static forRoot(): ModuleWithProviders {
            return {
                ngModule: SharedModule,
                providers: [MyService]
             }
         }
    }
    

    Then I changed it putting directly in the app.modules this way

    @NgModule({declarations: [
    AppComponent,
    NaviComponent],imports: [BrowserModule,RouterModule.forRoot(ROUTES),providers: [MoviesService],bootstrap: [MyService] })
    

    Obs: I'm using "@angular/core": "^6.0.2".

    I hope its help you.

提交回复
热议问题