0
我有两个连续的订阅在角2 两个独立的可观察的问题,我想:从坐标两个角上的两个独立的观测顺序订阅2
- 获取地点
- 附加此位置我的JSON
- JSON发送到服务器
我做的事情是这样的,我相信错:
this._locationService.geocode(this.location.latitude, this.location.longitude).
subscribe(position => {
this.location.city = this.findAddressPart(position, "locality", "long");
this.location.country = this.findAddressPart(position, "country", "long");
this._locationService.updateLocation(this.location)
.subscribe(
location => {
this.location = location;
this.submitted = true;
this.submitting = false;
}
);
});
这样我的DOM在我实际获取位置后只更新5-10s。
您是否尝试在角度区域运行此操作?使用this.zone.run(()=> {}) 您应该只在区域内运行位置分配 – galvan
这是如何工作的? – Mantas
请参阅这篇文章: http://www.joshmorony.com/understanding-zones-and-change-detection-in-ionic-2-angular-2/ – galvan