Search code examples
angulardependency-injectionangular2-services

DI Error in Angular2 component


Any help please i got this error when i try to inject the service to my component

i got this error when i try to inject the service to my component

  1. I created my service and decorated it with @Injectable()

  2. I added my service to my app.module in providers

  3. I tried to use the service in my component and inject it using the constructor

    but it gave me this error The Service

The App.moudle

the component


Solution

  • You forgot to add HttpModule to imports array

    @NgModule({
      imports: [
        BrowserModule,
        HttpModule,
        ...