如何使用AngularJS重定向到另一个页面?
2022-08-30 02:03:20
我正在使用ajax调用在服务文件中执行功能,如果响应成功,我想将页面重定向到另一个URL。目前,我正在通过普通的JS代码来执行此操作。但是我需要用AngularJS代码替换它。我已经在stackoverflow上寻找了各种解决方案,他们使用了.但我是AngularJS的新手,并且在实现它时遇到了麻烦。window.location = response['message'];
$location
$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
})