Estou fazendo o código, juntamente com os vídeos, porém ao tentar carregar os dados vindos da API, aparece o seguinte erro no browser:
Error: Uncaught (in promise): Error: No provider for Http!
Error
at Error (native)
Aqui está meu home.js
import { Component } from '@angular/core';
import { Http } from '@angular/http';
import { NavController, LoadingController } from 'ionic-angular';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
public carros;
constructor(
public navCtrl: NavController,
private _http: Http,
private _loadingCtrl: LoadingController) {
let loader = this._loadingCtrl.create({
content: 'Buscando novos carros. Aguarde...'
});
loader.present();
this._http
.get('https://aluracar.herokuapp.com')
.map(res => res.json())
.toPromise()
.then(carros => {
loader.dismiss();
this.carros = carros;
});
}
}
e o meu app.module.js
import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';
import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/toPromise';
@NgModule({
declarations: [
MyApp,
HomePage
],
imports: [
BrowserModule,
IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
HomePage
],
providers: [
StatusBar,
SplashScreen,
{provide: ErrorHandler, useClass: IonicErrorHandler}
]
})
export class AppModule {}