clusterBuddy
clusterBuddy

Reputation: 1554

Ionic2 - Runtime Error Uncaught (in promise): Error: No provider for Http

The Error:

Runtime Error Uncaught (in promise): Error: No provider for Http

And well, I do have a provider for HTTP, all registered. Any idea where I can look to debut this issue?

app.module.ts

import {NgModule, ErrorHandler} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {IonicApp, IonicModule, IonicErrorHandler} from 'ionic-angular';
import {MyApp} from './app.component';

import {StatusBar} from '@ionic-native/status-bar';
import {SplashScreen} from '@ionic-native/splash-screen';
import {GoldServiceProvider} from '../providers/gold-service/gold-service';

// ...

@NgModule({
    declarations: [
        MyApp,
        // ...
    ],
    imports: [
        BrowserModule,
        IonicModule.forRoot(MyApp)
    ],
    bootstrap: [IonicApp],
    entryComponents: [
        MyApp,
        // ...
    ],
    providers: [
        GoldServiceProvider,
        StatusBar,
        SplashScreen,
        {
            provide: ErrorHandler,
            useClass: IonicErrorHandler
        },
    ]
})
export class AppModule {
}

gold-service.ts: My Provider Service

import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/map';

@Injectable()
export class GoldServiceProvider {
    ...    
}

Upvotes: 2

Views: 1244

Answers (1)

sebaferreras
sebaferreras

Reputation: 44669

Providers have Http included by default, and in order to use Http in your app you will need to add the HttpModule to your app.module.ts:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule, ErrorHandler } from '@angular/core';
import { HttpModule } from '@angular/http';
...
  imports: [
    BrowserModule,
    HttpModule,
    IonicModule.forRoot(MyApp),
    IonicStorageModule.forRoot()
  ],
...

Upvotes: 3

Related Questions