title: Getting Geolocation coordinates using AngularJS
body: <p>I am trying to get the latitude and longitude of my position using AngularJS and Geolocation.
  This is the function in the controller in which I am assigning the values of the latitude and the longitude and printing them out to the browser console. The nearme() function is called,</p>
  
  <pre><code>  var mysrclat= 0; var mysrclong = 0;
    $scope.nearme = function($scope) {
      if (navigator.geolocation) {
          navigator.geolocation.getCurrentPosition(function (position) {
  
                  mysrclat = position.coords.latitude; 
                  mysrclong = position.coords.longitude;
          });
          console.log(mysrclat);
          console.log(mysrclong);
      }
  }
  </code></pre>
  
  <p>The issue is that, the first time, the coordinates print as 0, 0. Then, after that it prints the correct values of the coordinates. Why is it printing 0, 0 as the coordinates the first time?</p>