I encountered a strange error message saying "this is null" and I can't figure out what the issue is. Here is my demo on Stackblitz.com with an example code for your reference.
Component
ngOnInit() {
this.getCurrentLocation();
}
getCurrentLocation() {
navigator.geolocation.getCurrentPosition(position =>{
this.lat = position.coords.latitude;
this.lng = position.coords.longitude;
this.weatherInfo(this.lat, this.lng)
},function(){
this.origin = { lat: '3.140853', lng: '2.693207'};
console.log(this.origin)
this.weatherInfo(this.origin.lat, this.origin.lng)
})
}
weatherInfo(lat, lng){
console.log(lat, lng);
}