Javascript $ionicSlideBoxDelegate未填充动态幻灯片
我正在github上查看一个项目,它是一个onsen和Angle天气应用程序,我想在ionic中使用。不过我正试图改变一下。主要的想法是有一个爱奥尼亚幻灯片框,显示用户当天地理位置的天气,然后将其余的幻灯片预先输入全国各地的城市。我已经得到了地理定位工作,但我有困难添加更多的城市。我的服务:Javascript $ionicSlideBoxDelegate未填充动态幻灯片,javascript,angularjs,ionic-framework,Javascript,Angularjs,Ionic Framework,我正在github上查看一个项目,它是一个onsen和Angle天气应用程序,我想在ionic中使用。不过我正试图改变一下。主要的想法是有一个爱奥尼亚幻灯片框,显示用户当天地理位置的天气,然后将其余的幻灯片预先输入全国各地的城市。我已经得到了地理定位工作,但我有困难添加更多的城市。我的服务: .factory('$weather', function($q, $http) { var API_ROOT = 'http://api.openweathermap.org/data/2.5/'
.factory('$weather', function($q, $http) {
var API_ROOT = 'http://api.openweathermap.org/data/2.5/';
this.byJHB = function(coords) {
var deferred = $q.defer();
var long = '28.043631';
var lat = '-26.202271';
$http.jsonp(API_ROOT + '/weather?callback=JSON_CALLBACK&lat=' + lat + '&lon=' + long).then(
function(response) {
var statusCode = parseInt(response.data.cod);
if (statusCode === 200) {
deferred.resolve(response.data);
console.log(response.data);
}
else {
deferred.reject(response.data.message);
}
},
function(error) {
deferred.reject(error);
}
);
return deferred.promise;
};
this.byLocation = function(coords) {
var deferred = $q.defer();
$http.jsonp(API_ROOT + '/weather?callback=JSON_CALLBACK&lat=' + coords.latitude + '&lon=' + coords.longitude).then(
function(response) {
var statusCode = parseInt(response.data.cod);
if (statusCode === 200) {
deferred.resolve(response.data);
console.log(response.data);
}
else {
deferred.reject(response.data.message);
}
},
function(error) {
deferred.reject(error);
}
);
return deferred.promise;
};
return this;
});
和我的控制器:
.controller('WeatherController', function($scope, $window, $geolocation, $weather, $interval, $ionicSlideBoxDelegate) {
// Load saved cities from Local Storage.
$scope.places = angular.fromJson($window.localStorage.getItem('places') || '[]');
$scope.updateGeo = function() {
$geolocation.get().then(
function(position) {
$weather.byLocation(position.coords).then(
function(weather) {
$scope.localWeather = weather;
$ionicSlideBoxDelegate.update();
}
);
}
);
};
$scope.updateLocalWeather = function(coords) {
$weather.byJHB().then(
function(weather) {
$scope.byJHB = weather;
$ionicSlideBoxDelegate.update();
$scope.places.push(place);
$window.localStorage.setItem('places', angular.toJson($scope.places));
setImmediate(function() {
$ionicSlideBoxDelegate.update();
$ionicSlideBoxDelegate.currentIndex.setItem($scope.places.length + 1);
});
}
);
};
$scope.updateWeather = function() {
$scope.updateGeo();
$scope.updateGeo();
$interval($scope.updateWeather, 300000);
})
这是获取用户地理位置和显示天气数据,并创建附加幻灯片,但附加幻灯片不接收任何数据
有人有这方面的经验吗