Używam wywołania ajax do wykonywania funkcji w pliku usługi i jeśli odpowiedź się powiedzie, chcę przekierować stronę do innego adresu URL. Obecnie robię to za pomocą prostego js "window.location = response ['message'];". Ale muszę go zastąpić kodem angularjs. Szukałem różnych rozwiązań na stackoverflow, używali $ location. Ale jestem nowy w kątowym i mam problem z jego wdrożeniem.
$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
})