Extended Angular 2 无法注入Http服务

Extended Angular 2 Http service cannot be injected

我正在尝试扩展 Angular 2 中的 Http 服务以处理我需要包含在每个请求中的一些必需的 headers。我能够成功扩展它,添加我想要的 headers,然后调用 super.x() 操作来发送请求。我使用 解决了添加提供商的问题 ,导致此代码:

providers: [
    OAuthService,
    { provide: LoggerOptions, useValue: { level: environment.LogLevel }},
    Logger,
    {
      provide: APIClient,
      useFactory: (backend: ConnectionBackend, options: RequestOptions, oauthService: OAuthService, logger: Logger) => { return new APIClient(oauthService, backend, options, logger); },
      deps: [XHRBackend, RequestOptions, OAuthService, Logger]
    }, ...

我现在遇到编译错误:

ERROR in Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function (pos
ition 45:19 in the original .ts file), resolving symbol AppModule in [directory]/src/app/app.module.ts

如何将我的扩展程序注入 HTTP 服务并解决此错误?

谢谢。

更新 我能够使用以下代码编译应用程序:

  providers: [
    OAuthService,
    { provide: LoggerOptions, useValue: { level: environment.LogLevel }},
    Logger,
    {
      provide: APIClient,
      useFactory: apiClient,
      deps: [XHRBackend, RequestOptions, OAuthService, Logger]
    },
    IdentityService
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }

export function apiClient(backend: XHRBackend, options: RequestOptions, oauthService: OAuthService, logger: Logger): APIClient {
  return new APIClient(oauthService, backend, options, logger);
}

但我不确定为什么我需要创建一个函数来为我的 API 客户端包装构造函数。我可以像这样前进,但更愿意妥善解决这个问题。

Angulars 提前编译目前无法解析闭包 (() =>)。

另见 https://github.com/qdouble/angular-webpack2-starter#aot--donts