@Zewkin
Я у мамы фронтэндер

Почему не работет navigator.geolocation из сервисов?

angular.module('events.services', [])
.factory('EventService', function($http, $cordovaSQLite) {
	return {	
        getUserCoords: function() {    
            if (navigator.geolocation) {
                return navigator.geolocation.getCurrentPosition(function(position) {
                    return position;
                })
            }
        }
    }
})


Не могу понять, почему

EventService.getUserCoords();

возвращает undefined. Спасибо!
  • Вопрос задан
  • 131 просмотр
Пригласить эксперта
Ответы на вопрос 1
@telray
angular.module('events.services', [])
.factory('EventService', function($http, $cordovaSQLite) {
  return {	
        getUserCoords: function() {    
            if (navigator.geolocation) {
                var p;
                navigator.geolocation.getCurrentPosition(function(position) {
                    p = position;
                });
                return p;
            }
        }
    }
})
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы