2017-08-02 78 views
1

enter image description here有一些误差httpclientmodule: 我有app.module.ts且有代码:角2误差httpcliendmodule

import { NgModule }  from '@angular/core'; 
import { BrowserModule } from '@angular/platform-browser'; 
import { FormsModule } from '@angular/forms'; 
import { AppComponent } from './app.component'; 
import {HttpClientModule } from '@angular/http'; 

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

和错误: nodemodules/@角/ HTTP/HTTP没有导出部件'HttpClientModule'

+0

看到在角HTTP和之间的HTTPClient [差分4?](https://stackoverflow.com/questions/45129790/difference-between-http-and-httpclient-in-angular-4/451 29865#45129865) –

回答

4

应该从@angular/common/http进口

import {HttpClientModule} from '@angular/common/http'; 

确保ÿ OU已经安装[email protected]^4.3.0changelog

又见文档

Plunker Example

+0

我试了一下,但有错误:无法找到模块“@角/普通/ HTTP”您正在使用哪个版本的角度 – shoopik

+0

@shoopik? – yurzui

+0

毫米,我怎么检查它?在JSON我看下:“@角/常见”:“〜4.0.0”, “@角/编译”:“〜4.0.0”, – shoopik