angular2-http
来源:互联网 发布:java退格 编辑:程序博客网 时间:2024/06/09 22:09
- 提供HTTP服务
- http是angular的HTTP库所提供的一系列服务之一
import { Http, Response, Headers, RequestOptions} from '@angular/http';
- 注册http服务:把HttpModule添加到AppModule的imports列表中
import { NgModule } from '@angular/core';import { BrowserModule } from '@angular/platform-browser';import { HttpModule } from '@angular/http';import { AppComponent } from './app.component';@NgModule({ imports: [ BrowserModule, HttpModule ], declarations: [ AppComponent ], bootstrap: [ AppComponent ], exports: []})export class AppModule { }
- 使用http.get()获取数据
getHeroes(): Promise<Hero[]> { return this.http.get(requestUrl) .toPromise() .then(response => response.json().data as Hero[]) .catch(this.handleError); }
- 处理响应对象
//从返回的response中提取数据,通过then的方式提取.then(response => response.json().data as Hero[])
阅读全文
0 0
- Angular2-http
- angular2-http
- Angular2 Http
- Angular2 http服务
- Angular2(九)--http
- Angular2 Http的使用
- Angular2 http服务
- angular2使用Http服务
- angular2 Http请求
- Angular2学习 Http通信
- Angular2 http模块
- angular2 http post请求
- angular2.0 http示例代码
- Angular2 Http拦截器 Interceptor 实现
- angular2-英雄指南教程http请求
- 基于angular2 的 http服务封装
- angular2实现统一的http请求头
- angular2
- 八大排序算法之-选择排序 java代码
- Lintcode98 Sort List solution 题解
- 计蒜客 方程的解数
- 深入浅出Java多线程--慕课网笔记
- 【洛谷P2423】双塔
- angular2-http
- python:numpy 文件存取
- How Many Tables(并查集)
- Java获取客户端IP
- 设计模式之外观模式
- 两个输出文件名解析为同一个输出路径:“obj\x86\Debug\xxxxxxxxxxxxx.resources”
- 什么是java 序列化,如何实现java 序列化?
- 关于官网例子程序的运行失败【tutorial文件夹】
- 八大排序算法之-堆排序 java代码