八、请求post、get、jsonp

1.创建个 news 组件使用

2.在module.ts 引入模块

 

3.在使用的“Component”中不一样。这里是 http和jsonp

4.编写get请求查看效果

(1).编写好的get请求,点击按钮,控制台出现了效果。

(2).读获取到的数据进行精准获取,[ ] 或者 .xx

 

(3).获取到的对象转换成 json 对象

 

(4).获取数据进行遍历

(5).Jsonp请求

 

5.Post请求

(1).对比 get 请求,在“Component”组件上多定义一个 Headers 请求头

(2).

 

 

 

 问题

1.'HttpModule' is declared but its value is never read.ts(6133) Cannot find module '@angular/http'.ts(2307)

 

解决方法:需要安装一下 npm install @angular/http@latest

2.error TS2307: Cannot find module 'rxjs-compat/Observable'

解决方法:重新 npm install 

posted @ 2019-03-17 20:34  钧天府人  阅读(860)  评论(0)    收藏  举报