Angular EXCEPTION: No provider for Http
Full error message
I am getting the EXCEPTION: No provider for Http! in my Angular app. What am I doing wrong?
import {Http, Headers} from 'angular2/http';
import {Injectable} from 'angular2/core'
@Component({
selector: 'greetings-ac-app2',
providers: [],
templateUrl: 'app/greetings-ac2.html',
directives: [NgFor, NgModel, NgIf, FORM_DIRECTIVES],
pipes: []
})
export class GreetingsAcApp2 {
private str:any;
constructor(http: Http) {
this.str = {str:'test'};
http.post('http://localhost:18937/account/registeruiduser/',
JSON.stringify(this.str),
{
headers: new Headers({
'Content-Type': 'application/json'
})
});Solutionsource: stackoverflow \u2197
Import the HttpModule import { HttpModule } from '@angular/http'; @NgModule({ imports: [ BrowserModule, HttpModule ], providers: [], declarations: [ AppComponent ], bootstrap: [ AppComponent ] }) export default class AppModule { } platformBrowserDynamic().bootstrapModule(AppModule); Ideally, you split up this code in two separate files. For further information read: https://v2.angular.io/docs/ts/latest/cookbook/rc4-to-rc5.html https://v2.angular.io/docs/ts/latest/guide/ngmodule.html
API access
Get this solution programmatically \u2014 free, no authentication.
curl https://depscope.dev/api/error/c3e29b2156f4a22f79316dd3b8cad5a84f26dc313221200d17beac4f7f4e130ahash \u00b7 c3e29b2156f4a22f79316dd3b8cad5a84f26dc313221200d17beac4f7f4e130a