1
我在我的ionic1應用程序中的控制器中進行HTTP調用。有時互聯網連接速度很慢,我想暫停腳本。例如,當存在20秒無響應警報應該彈出爲ionic1中的http請求設置超時值angularjs
.controller('account_statement_ctrl', function($scope, $http, $ionicLoading, $ionicPopup, $cordovaToast, $location, $ionicModal, $filter) {
$scope.account_number = localStorage.getItem("account_number");
///alert if connection fails
$scope.connect = function() {
var alertPopup = $ionicPopup.alert({
title: 'Error',
template: '<p align="center">Internet Connectivity Problem</p>',
});
};
$scope.nobill = function() {
var alertPopup = $ionicPopup.alert({
title: 'Error',
template: '<p align="center">Not Found</p>',
});
};
$scope.acc_request = function() {
$scope.start_date = $filter('date')($scope.sdate, "yyyy-MM-dd");
$scope.end_date = $filter('date')($scope.edate, "yyyy-MM-dd");
$ionicLoading.show({
template: '<p>Processing Request</p><ion-spinner></ion-spinner>'
});
$http.get("http://localhost/app/state?account_number=" + $scope.account_number).success(function(data) {
$scope.statement = data.data
//console.log(JSON.stringify(data.data))
{
$ionicLoading.hide();
}
})
}
})
你能把它寫成我的腳本嗎? – user6579134
我添加了一個基本片段 –