ฉันใช้การโทร ajax เพื่อใช้งานฟังก์ชันในไฟล์บริการและหากการตอบสนองสำเร็จฉันต้องการเปลี่ยนเส้นทางหน้าเว็บไปยัง URL อื่น ขณะนี้ฉันกำลังทำสิ่งนี้โดยใช้ js แบบง่าย "window.location = response ['message'];" แต่ฉันต้องแทนที่ด้วยรหัส angularjs ฉันได้ดูวิธีแก้ปัญหาต่างๆใน stackoverflow พวกเขาใช้ตำแหน่ง $ แต่ฉันใหม่สำหรับเชิงมุมและมีปัญหาในการใช้งาน
$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
})