浅谈angular2的http请求返回结果的subcribe注意事项

时间:2017-03-01    点击:147   

实例如下:

this.monitorSer.getVehicleLonAndLat(vehicleIds)
 .subscribe(
  data => {
   //将data下的data字符串转化为vehdata数组
   this.vehData=JSON.parse(data.data);
   //功能实现
   this.loadOverLay();
  },

  error => this.errorMessage = <any>error

);//错误处理

subscribe()异步处理,如果需要用返回的数据,最好把方法写在里面。

以上这篇浅谈angular2的http请求返回结果的subcribe注意事项就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持本站。

Ajax实现不刷新取最新商品
JS中使用 after 伪类清除浮动实例
轻松学习Javascript闭包
node.js实现回调的方法示例
JQ中$(window).load和$(document).ready区别与执行顺序
> 返回     
地址:上海市普陀区胶州路941号长久商务中心 电话: QQ:
© Copyright 2012 上海网络 Product All Rights Reserved