在Angular 4.0.0中注入Http

在Angular 4.0.0中注入Http,angular,Angular,当我尝试在引导应用程序模块之前调用ajax请求时。我越来越累了 let injector = ReflectiveInjector.resolveAndCreate([ Http, BrowserXhr, {provide: RequestOptions, useClass: BaseRequestOptions}, {provide: ResponseOptions, useClass: BaseResponseOptions

当我尝试在引导应用程序模块之前调用ajax请求时。我越来越累了

  let injector = ReflectiveInjector.resolveAndCreate([
        Http,
        BrowserXhr,
        {provide: RequestOptions, useClass: BaseRequestOptions},
        {provide: ResponseOptions, useClass: BaseResponseOptions},
        {provide: ConnectionBackend, useClass: XHRBackend}
      ]);
      this._http = injector.get(Http);

您需要将HttpModule注册到应用程序中。 从'@angular/http'导入{HttpModule}

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

您需要将HttpModule注册到应用程序中。 从'@angular/http'导入{HttpModule}

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

我认为这应该用angularjs标记,而不是angularjs。还有,您得到的错误是什么。@Senthil。用完整的错误信息更新屏幕截图您是否尝试创建如中所示的提供商?请参考下面的链接查看此repo以进行http调用我认为这应该用angularjs标记,而不是angularjs。还有,您得到的错误是什么。@Senthil。使用完整的错误消息更新屏幕截图是否尝试创建如中所示的提供程序?请参阅下面的链接查看此repo以进行http调用