title: Using Google Maps and Angular JS. Trying to store coordinates in variable
body: <p>FYI, I'm new to AngularJS. I'm trying to store coordinates of marker selected in Google Maps in a variable. I am able to log the coordinates once I select a point on the map but I can't figure out why $scope.map.markers is returning "undefined" in addSesh(). Please let me know if you need further clarification. Thanks in advance!</p>
  
  <pre><code>angular
    .module('surfSup')
    .controller('SessionController', function($scope, $location, SessionService, CacheEngine, $rootScope) {
  $scope.addSesh = addSesh;
    function addSesh () {
        $scope.sessionObjs = {
          time: $scope.time ? $scope.time.toISOString().slice(0,19) : "",
          isSurf: $scope.suppy,
          location: $scope.location
        };
        console.log("session obj", $scope.sessionObjs);
        console.log("map coords: ", $scope.map.markers);
        SessionService.addSession($scope.sessionObjs).then(function(res){
          console.log('session created', res);
          $location.path('/sessions');
      }
  $scope.map = {
        center: {
            latitude: 32.7799400,
            longitude:-79.9341970
        },
        zoom: 11,
        markers: [],
        events: {
        click: function (map, eventName, originalEventArgs) {
            var e = originalEventArgs[0];
            var lat = e.latLng.lat(),lon = e.latLng.lng();
            var marker = {
                id: Date.now(),
                coords: {
                    latitude: lat,
                    longitude: lon
                }
            };
            $scope.map.markers.push(marker);
            console.log('MARKERS:', $scope.map.markers);
            window.glow = $scope.map.markers;
            $scope.$apply();
        }
    }
    };
  </code></pre>