i'm trying to set a timeout for this script and also show a popup when the timeout is due
我正在尝试为此脚本设置超时,并在超时到期时显示弹出窗口
$scope.mainloginAlert = function() {
var alertPopup = $ionicPopup.alert({
title: 'Error',
template: '<p align="center">Incorrect Username or Password</p>',
});
};
$scope.mainlogin= function(){
$ionicLoading.show({template: '<p>Please Wait...</p><ion-spinner></ion-spinner>'});
event.preventDefault();
$http.post("http://web.usersite.com/scripts/login.php",
{'username':$scope.username,'pwd':$scope.pwd})
.success(function(data){
console.log(JSON.stringify(data));;
{$ionicLoading.hide();}
if(data==="Incorrect Username or Password"){
$scope.mainloginAlert()
}
else{
if(data != "Incorrect Username or Password"){
localStorage.setItem("username",(data[0].username));
$window.location.href = 'userpage.html';
}
}
}).error(function(error){
console.error(error);
});
}
}])
Cos without a timeout for the loader to stop spinning. it will keep on spinning even if there's no internet connection
Cos没有超时装载器停止旋转。即使没有互联网连接,它也会继续旋转
2 个解决方案
#1
0
you'll want to use angular's wrapper for this:
你会想要使用angular的包装器:
$scope.mainlogin= function(){
$timeout(hideLoader, 5000)
function hideLoader() {
$ionicLoader.hide()
}
}
#2
0
js code: this loading or popup will be shown till 2.5 seconds, that's the hint, replace with your credentials. I hope it works
js代码:此加载或弹出窗口将显示为2.5秒,这是提示,替换为您的凭据。我希望它有效
$scope.post = function () {
$ionicLoading.show({
template: 'Posting ...'
});
console.log('Posting ', $scope.load);
$timeout(function () {
$ionicLoading.hide();
$scope.closePost();
}, 340);
};
#1
0
you'll want to use angular's wrapper for this:
你会想要使用angular的包装器:
$scope.mainlogin= function(){
$timeout(hideLoader, 5000)
function hideLoader() {
$ionicLoader.hide()
}
}
#2
0
js code: this loading or popup will be shown till 2.5 seconds, that's the hint, replace with your credentials. I hope it works
js代码:此加载或弹出窗口将显示为2.5秒,这是提示,替换为您的凭据。我希望它有效
$scope.post = function () {
$ionicLoading.show({
template: 'Posting ...'
});
console.log('Posting ', $scope.load);
$timeout(function () {
$ionicLoading.hide();
$scope.closePost();
}, 340);
};