title: Get coordinates of current location in angular
body: <p>I created the following function in a service, to get the coordinates of the current location and store them in 2 variables:</p>
  
  <pre><code>  getCurrentLocation() {
      if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(position =&gt; {
  
          this.currLat = position.coords.latitude;
          this.currLng = position.coords.longitude;
        });
      }
      else {
        alert("Geolocation is not supported by this browser.");
      }
    }
  </code></pre>
  
  <p>how can I return the coordinates through this function in order to use them in a component?</p>