angular $state.go跳转在异步响应中页面不起效

if($scope.loginForm.$valid) {
                var postData = {
                    username : $scope.username,
                    password : $scope.loginForm.password.$modelValue,
                    smsCode : $scope.messageCode
                };
                $scope.method = "post";
                $scope.url = BASE_URL + "/user/login/users";
                $http({
                    method:$scope.method,
                    url: $scope.url,
                    data : postData,
                    headers : {
                        "Content-Type": 'application/json'
                    }
                }).then( function (response) {
                    console.log(response);
                    if(response.data.success == true){
                        $cookieStore.put("userMessage", response);
                        $state.go("sidebar.overall");

                        if($cookieStore.get('userMessage')){
                            $scope.uMessage = $cookieStore.get('userMessage');
                            $http({
                                method: 'GET',
                                url: BASE_URL + '/user/roles/privileges/parts/' + $scope.uMessage.data.data.user.roleId,
                                headers : {
                                    "Content-Type": 'application/json'
                                }
                            }).then(function (res){
                                localStorage.setItem('permitInfo',JSON.stringify(res.data));
                            }, function(res){
                                console.log(res);
                            });
                        }
                    }
                }, function (response) {
                    console.log(response);
                });
            }

后端返回成功的数据,但是没有跳转页面,第二次在刷新页面的情况可以跳转页面,求原因?
angular的版本 1.6.2

阅读 2.9k
1 个回答

两个请求分别是什么作用啊?

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进