-1
У меня есть эта функция, которая загружает файл JSON и заполняет область. Если он не работает, он загружает ионный пакет с двумя вариантами: «ОК» и «Повторить». Я хотел бы возобновить функцию повтораФункция возврата из функции
Вот мой код
$scope.loadEvents = function() {
$http.get('https://api.paris.fr/api/data/1.4/QueFaire/get_activities/?token=[foobar]&cid=3,9,18,20,16,10,4,37,1,29,30,11,42,25,5,33,8,39,6,40,17,38,34,32,2,44,23&tag=6,4,7,44,2,45,48&created=0&start=0&end=0&offset=1&limit=50',{header : {'Content-Type' : 'application/json; charset=UTF-8'}})
.success(function (data) {
$ionicLoading.hide();
$scope.products = data.data;
var randomProduct = Math.round(Math.random() * ($scope.products.length - 1))
$scope.currentProduct = angular.copy($scope.products[randomProduct]);
$scope.currentProduct.image = $scope.checkhttp();
})
.error(function (data, status, headers, config) {
$ionicLoading.hide();
$scope.errorMessage = "Couldn't load the list of events, error # " + status;
var alertPopup = $ionicPopup.confirm({
title: 'Could not load list of events, error #0',
template: '',
buttons: [
{text: 'OK'},
{
text: '<b>Retry</b>',
type: 'button-positive',
onTap: function(e) {
console.log("Reessayer");
//retry loadEvents()
return false;
}}]
});
console.log($scope.errorMessage);
});
}
$scope.loadEvents();
Просто извлеките http-вызов в функциональную переменную –
Что значит? –