I am using ajax call to perform functionality in a service file and if the response is successful, I want to redirect the page to another url.(我正在使用ajax调用来执行服务文件中的功能,如果响应成功,我想将页面重定向到另一个URL。)
Currently, I am doing this by using simple js "window.location = response['message'];".(目前,我通过使用简单的js“window.location = response ['message'];”来做到这一点。) But I need to replace it with angularjs code.(但我需要用angularjs代码替换它。) I have looked various solutions on stackoverflow, they used $location.(我在stackoverflow上看了各种解决方案,他们使用了$ location。) But I am new to angular and having trouble to implement it.(但我是棱角分明并且很难实现它。)
$http({
url: RootURL+'app-code/common.service.php',
method: "POST",
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
dataType: 'json',
data:data + '&method=signin'
}).success(function (response) {
console.log(response);
if (response['code'] == '420') {
$scope.message = response['message'];
$scope.loginPassword = '';
}
else if (response['code'] != '200'){
$scope.message = response['message'];
$scope.loginPassword = '';
}
else {
window.location = response['message'];
}
// $scope.users = data.users; // assign $scope.persons here as promise is resolved here
})
ask by Farjad Hasan translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…