【发布时间】:2020-04-18 19:46:40
【问题描述】:
如何将 locationId 数组传递给服务?
我有一组位置 ID
locationArr=[40871, 60009, 38149, 40868, 43240, 15299, 53897, 40976, 38151, 23183, 38152, 78579, 23180, 40977, 23176, 39565, 40884, 15298, 38147, 40966, 39669]
其实我需要将 locationArr 传递给http://192.168.7.45:9200/location/_doc/+locationArr
我需要将 locationArr 上存在的 locationId 数组传递给服务,以获取数组 locationArr 上每个 locationId 的 GPS1 纬度和经度。
服务通过 locationId 仅针对一个 locationId 获取位置,但对于位置数组,这是我的问题
getLocationData(id: number) {
console.log("server "+id)
return this.http.get('http://192.168.7.45:9200/location/_doc/'+id);
}
那么请问如何在位置数组中通过循环来实现它
calling service
this.partDetailsService.getLocationData(this.LocationId).subscribe(res => {
this.dataLocation = res['_source']['GPS1'];
var loc = this.dataLocation.split(',');
this.lat = loc[0].trim();
this.lng = loc[1].trim();
【问题讨论】:
标签: angular typescript angular-material angular7 angular-resource