I'm trying to modify an object latitude and longitude values after I submit the form because after submiting it I need to pass a geocode function to it's address.
I'm using this function to modify the lat and lng:
setLanLon(address : string){
this.getLatLon(address).subscribe(
data => {
this.foo.lat= data.lat();
this.foo.lng= data.lng();
},
error => {
console.log(error);
});
}
And the function that is called on the form submit and in which I'm calling the function that modifies the values is this one:
edit() {
this.setLanLon(this.foo.address);
this.service.update(this.foo)
.subscribe(
data => {
this.router.navigate(['/home']);
},
error => {
console.log(error);
});
}
But the lat and lng values that I receive in the service are the original values not the ones I modify with my function. What am I doing wrong here? Thanks in advance.
data.lat()anddata.lng(), shouldn't it be justdata.latanddata.lng, or how does your response look like? And yourupdate-method is fired beforefoohas been manipulated. Try executing the method after setting the new values:.... this.foo.lng= data.lng; this.service.update(this.foo)....