本文介绍了现在Http是模块,Angular2 rc.5如何注入HTTP_PROVIDERS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Angular2 rc.5现在所有都是模块了,如何注入HTTP_PROVIDERS ...
Angular2 rc.5 how to inject HTTP_PROVIDERS now that all are modules...
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,您必须在@NgModule
内的imports array
中添加HttpModule
以获得更多详细信息,请检查此链接
For RC5 you have to add the HttpModule
in imports array
inside @NgModule
for more detail check this 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 {}
这篇关于现在Http是模块,Angular2 rc.5如何注入HTTP_PROVIDERS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!