我得到的EXCEPTION:没有提供商Http!在我的Angular 2.我做错了什么?
- 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'
- })
- });
- import { HttpModule } from '@angular/http';
- @NgModule({
- imports: [ BrowserModule,HttpModule],declarations: [ AppComponent ],bootstrap: [ AppComponent ]
- })
- export default class AppModule { }
- platformBrowserDynamic().bootstrapModule(AppModule);
> https://angular.io/docs/ts/latest/cookbook/rc4-to-rc5.html
> https://angular.io/docs/ts/latest/guide/ngmodule.html