Angular2 rc.5现在Http是模块,如何注入HTTP_PROVIDERS

时间:2016-08-11 18:34:36

标签: angular

Angular2 rc.5如何注入HTTP_PROVIDERS,现在所有都是模块...

 var injector = ReflectiveInjector.resolveAndCreate(
            [
                TodoService,
                TodoAction,
                HTTP_PROVIDERS, // <----- no longer injectable
                TodoStatsModel,
                {provide: CommBroker, useClass: CommBroker},
                {provide: AppStore, useValue: th[![i][1]][1]s.appStore}
            ]);

的问候,

肖恩

1 个答案:

答案 0 :(得分:4)

对于RC5,您必须在HttpModule imports array内添加@NgModule以获取更多详情,请查看此link

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { HttpModule } from '@angular/http';

@NgModule({
  imports: [BrowserModule, HttpModule],
  declarations: [AppComponent],
  bootstrap: [AppComponent]
})
export class AppModule {}