Tôi đang sử dụng lệnh gọi ajax để thực hiện chức năng trong tệp dịch vụ và nếu phản hồi thành công, tôi muốn chuyển hướng trang sang url khác. Hiện tại, tôi đang làm điều này bằng cách sử dụng js đơn giản "window.location = reply ['message'];". Nhưng tôi cần thay thế nó bằng mã angularjs. Tôi đã xem xét các giải pháp khác nhau trên stackoverflow, họ đã sử dụng $ location. Nhưng tôi mới đến góc cạnh và gặp khó khăn để thực hiện nó.
$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
})