Angular2 rc.5 现在如何注入(inject) 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}
            ]);

问候,

肖恩

最佳答案

对于 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 {}

关于Angular2 rc.5 既然 Http 是模块,那么如何注入(inject) HTTP_PROVIDERS,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/38903798/

10-16 19:42