Okay so what I want to do is wait for a location service to fetch the coords and then I’m going to execute my other functions(lines of code).
//in my TS file.
this.locationAccuracy.request(this.locationAccuracy.REQUEST_PRIORITY_HIGH_ACCURACY)
.then(() => {
this.locService.getLocation();
//Execute this function only when you have got the coords from this locService.
this.getList();
}, error => this.ui.showToast('Please enable GPS location', false, '')
);
IN my Service file
this.geolocation.watchPosition()
.filter((p) => p.coords !== undefined) //Filter Out Errors
.subscribe(position => {
console.log(position.coords.latitude + ' ' + position.coords.longitude);
this.lat = position.coords.latitude;
this.lng = position.coords.longitude;
});
What to do ?
Please help, I think this can be achieved using async/await but I dont know how to use them?