Javascript 显示“角度”对话框时的处理超时
我有一个AngularJS应用程序 我想在会话超时时处理错误。发生时,我将用户发送到登录页面。 除了用户单击打开对话框的按钮外,它始终对我有效 我创建ErrorService是为了处理这种情况:Javascript 显示“角度”对话框时的处理超时,javascript,angularjs,session-timeout,Javascript,Angularjs,Session Timeout,我有一个AngularJS应用程序 我想在会话超时时处理错误。发生时,我将用户发送到登录页面。 除了用户单击打开对话框的按钮外,它始终对我有效 我创建ErrorService是为了处理这种情况: app.service('ErrorService', ['$modal', 'AlertService', function ($modal, AlertService) { this.handleError = function(error) { //ses
app.service('ErrorService', ['$modal', 'AlertService',
function ($modal, AlertService) {
this.handleError = function(error) {
//session timeout
if ((error.data !== "" || error.data !== null) &&
(error.status === 403)) {
window.location.href = "/webapps/";
} else {
if (error.data !== "" || error.data !== null)
AlertService.alert("status: " + error.data);//this will show the actual error thrown from the server if exist, if not exist it will show the http error text
else
AlertService.alert("status: " + error.statusText);
}
};
}]);
在我的应用程序中,当我单击按钮时,我有下一个代码:
this.sendMessageToAssignedUnits = function (size) {
var modalInstance = $modal.open({
templateUrl: 'Screen.html',
controller: 'ModalInstanceCtrl',
size: size
});
modalInstance.result.then(function (response) {
var simpleTextMessage = "Yo yo";
$http.post(response.url, simpleTextMessage)
.then(function (response) {
}, function (error) {
ErrorService.handleError(error);
}
);
}, function () {
console.log('Modal dismissed at: ' + new Date());
});
};
在这种情况下,我无法进入错误服务。
我去登录页面,但背景看起来像在前面 那么问题出在哪里,模态没有消失或者重定向到登录??模态被打开,里面有登录页面。。。我只想看到没有模式的登录页面。。。或者直接转到登录页面…根据您创建模式对话框所使用的内容,将对话框视为一个单独的窗口。因此,当会话过期时,它将在对话框中过期。作为错误处理的一部分,您应该首先关闭对话框,然后更改window.location。您可以调查一个事件,并在会话到期时拥有应用程序重定向到的路由。