I'm trying to use the http module. After looking around for a bit I saw that the only two options for fixing this were to import the module (which i've done) or use HTTP_PROVIDERS which is deprecated for me.
I've imported it here:
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { HttpModule } from "@angular/http";
import { AppComponent } from './app.component';
@NgModule({
imports: [BrowserModule, HttpModule],
declarations: [AppComponent],
bootstrap: [AppComponent]
})
export class AppModule { }
and this is my boot.ts
import 'core-js';
import 'zone.js/dist/zone';
import {bootstrap} from '@angular/platform-browser-dynamic';
import {ROUTER_PROVIDERS} from '@angular/router';
import {AppComponent} from './app.component';
bootstrap(AppComponent, [
ROUTER_PROVIDERS
]);
And i'm trying to use it here :
import {Injectable} from '@angular/core';
import {Headers,Http} from '@angular/http';
@Injectable()
export class ApiService {
constructor(private _http:Http){}
}
but for some reason It's giving me the error: EXCEPTION: Error: Uncaught (in promise): EXCEPTION: Error in :0:0 ORIGINAL EXCEPTION: No provider for Http!
The are the versions i'm using:
"dependencies": {
"@angular/common": "2.0.0-rc.1",
"@angular/compiler": "2.0.0-rc.1",
"@angular/core": "2.0.0-rc.1",
"@angular/http": "^2.0.1",
"@angular/platform-browser": "2.0.0-rc.1",
"@angular/platform-browser-dynamic": "2.0.0-rc.1",
"@angular/router": "2.0.0-rc.1",
"es6-shim": "^0.35.0",
"reflect-metadata": "0.1.3",
"rxjs": "5.0.0-beta.6",
"systemjs": "^0.19.27",
"zone.js": "^0.6.12"
},
any clue why I would still be getting this error after importing the module?
@NgModule
didn't exist untilrc.5
. You also havehttp: ^2.0.1
while the rest arerc.1
. They aren't compatible. If this is a new project, just start with2.0.1
across the board.