I’m trying to get an alert box to popup when the http.get url cannot be loaded to tell the user it’s an internet connectivity issue and some features may be limited. For some reason it isn’t working.
Here’s my code:
$scope.doRefresh = function() {
$http.get('')
.success(function(data) {
$scope.data = data;
window.localStorage.setItem("data", JSON.stringify(data));
})
.error(function() {
$ionicLoading.hide()
if(window.localStorage.getItem("data") !== undefined) {
$scope.data = JSON.parse(window.localStorage.getItem("data"));
$scope.data = data;
}
$scope.showAlert = function() {
var alertPopup = $ionicPopup.alert({
title: 'Internet Connectivity',
template: 'Some features might be limited'
})
}
})
.then(function() {
$ionicLoading.hide()
});
}