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

 更新时间:2017年03月01日 11:09:59   投稿:jingxian  
下面小编就为大家带来一篇浅谈angular2的http请求返回结果的subcribe注意事项。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧

实例如下:

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注意事项就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。

相关文章

最新评论