Angular2提供

时间:2016-09-19 15:10:59

标签: angular provider

我今天将我的项目升级到Angular RC到Final,我有一个问题要转换=>

provide(Http, {
   useFactory: (xhrBackend: XHRBackend, requestOptions: RequestOptions, accountEventService: AccountEventsService) => {
       return new HmacHttpClient(xhrBackend, requestOptions, accountEventService);
   },
   deps: [XHRBackend, RequestOptions, AccountEventsService],
   multi: false
}

我尝试在最终版本中使用相同的代码,但我没有找到解决方案。

感谢您的帮助

1 个答案:

答案 0 :(得分:1)

语法已更改为对象文字,如:

{provide: Http, 
   useFactory: (xhrBackend: XHRBackend, requestOptions: RequestOptions, accountEventService: AccountEventsService) => {
       return new HmacHttpClient(xhrBackend, requestOptions, accountEventService);
   },
   deps: [XHRBackend, RequestOptions, AccountEventsService],
   multi: false
}