Upgrade angular 4 to 7 @angular/http to @angular/common/http

大憨熊 提交于 2019-12-22 10:53:16

问题


Currently, I am upgrading my Angular project4 using webpack to Angular7.
I stuck in one step

Switch from HttpModule and the Http service to HttpClientModule and the HttpClient service. HttpClient simplifies the default ergonomics (You don't need to map to json anymore) and now supports typed return values and interceptors.

About this step I need to replace from rom HttpModule and Http to HttpClientModule and HttpClient. Update from Http to HttpClient, are there any script to help like
$rxjs-5-to-6-migrate -p src/tsconfig.app.json


回答1:


just change your imports from HttpModule to HttpClientModule and Http to HttpClient

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


来源:https://stackoverflow.com/questions/53778496/upgrade-angular-4-to-7-angular-http-to-angular-common-http

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!