Get coordinates of current location in angular

Just in case if you want continually request the position, then use

navigator.geolocation.watchPosition(res => ...

You could return a promise.

locationService.ts

 getPosition(): Promise<any>
  {
    return new Promise((resolve, reject) => {

      navigator.geolocation.getCurrentPosition(resp => {

          resolve({lng: resp.coords.longitude, lat: resp.coords.latitude});
        },
        err => {
          reject(err);
        });
    });

  }

component.ts

  this.locationService.getPosition().then(pos=>
  {
     console.log(`Positon: ${pos.lng} ${pos.lat}`);
  });