Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

StaticInjectorError[e -> e]: NullInjectorError: No provider for e

Tags:

angular

In my app.module.ts

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    MaterialModule,
    FlexLayoutModule,
    BrowserAnimationsModule,
    AppRoutingModule,
    HttpClientModule,
    FormsModule,
    ReactiveFormsModule,
    MyAppModule
  ],
  providers: [
    AuthenticationService,
    AuthGuardService,
    MyAppService
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }

In my AuthGuardService:

@Injectable({
  providedIn: 'root'
})
export class AuthGuardService implements CanActivate {

I've already put the HttpClientModule and even add providedIn in my authguard, but still I encounter this error. I am using angular 7.

like image 707
iPhoneJavaDev Avatar asked Mar 05 '19 02:03

iPhoneJavaDev


1 Answers

Remove all the services from providers as you already have added providedIn: 'root'

like image 53
Sajeetharan Avatar answered Oct 20 '22 19:10

Sajeetharan