У меня есть этот контроллер, который имеет несколько функций, которые называют друг друга. При успехе я хочу вернуть что-то отображаемое (расположенное в последней функции). По какой-то причине, без ошибок, возврат не работает, но console.log. Может кто-то, пожалуйста, скажите мне, почему возвращение не работает и дайте мне решение, пожалуйста. Спасибо!Как методы области видимости в AnjularJS
.controller("dayController", function(){
.controller("weatherController", function(){
this.currentWeatherToDisplay = function(){
if(navigator.geolocation){
navigator.geolocation.getCurrentPosition(gotLocation,initialize);
}
else{
alert("Device does not support geolocation");
initialize();
}
};
var currentLocation;
//get the location coords
function gotLocation(pos){
var crd = pos.coords;
currentLocation = loadWeather(crd.latitude+','+crd.longitude);
initialize();
}
function initialize(){
if(!currentLocation){
loadWeather("Washington, DC");
}
else{
loadWeather(currentLocation);
}
}
function loadWeather(location){
$.simpleWeather({
location: location,
woeid: '',
unit: 'f',
success: function(weather) {
var html = weather.temp+'°'+weather.units.temp;
console.log(html);
return html;
},
error: function(error) {
console.log(error);
return error;
}
});
}
});
не повезло! Я не понимаю, почему он не возвращает глобальную область действия! – nehas