[英]How to send data in http service using angular 2
我有一个网址数组,需要将其作为http服务网址路径发送,并根据响应类型生成结果。 示例数组如下。
this.urlArray = ["www.test.com","www.test2.com"];
我遍历数组并生成div,并将URL作为参数发送到http服务,并基于请求类型(例如“超时”),成功和错误将更改div颜色。 有人可以告诉我该如何继续吗?
来自https://angular.io/docs/ts/latest/guide/server-communication.html
addHero (name: string): Observable<Hero> {
let headers = new Headers({ 'Content-Type': 'application/json' });
let options = new RequestOptions({ headers: headers });
return this.http.post(this.heroesUrl, /*{ name }*/ this.urlArray, options)
.map(this.extractData)
.catch(this.handleError);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.