Angular 2 cli HTTP_PROVIDERS没有导出成员问题

时间:2017-03-27 10:41:13

标签: angular

我是Angular 2的新手,无法从@ angular / http导入HTTP_PROVIDERS。我经历了许多类似的问题,但没有一个与CLI有关。

任何人都可以帮我将HTTP_PROVIDERS添加到Angular-cli

为什么我们使用rxjs?

enter image description here

2 个答案:

答案 0 :(得分:2)

角度2.x.x中没有HTTP_PROVIDERS它已被删除。自Angular rc5以来它已被弃用。

如果您想使用Http服务,只需在模块中导入HttpModule

答案 1 :(得分:0)

您不需要导入HTTP_PROVIDERS,只需执行此类操作

即可
import { HttpModule, JsonpModule } from '@angular/http';
@NgModule({
  imports: [
    // other NgModule
    HttpModule,
    JsonpModule
  ],
  //...
})
export class AppModule { }

why are we using rxjs? 因为rxjs是Angular的一部分,所以HTTP由Observable包装。