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