加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angularjs – $location.path不工作

发布时间:2020-12-17 08:09:17 所属栏目:安全 来源:网络整理
导读:当用户输入正确的用户名和密码时,我想重定向到另一个位置。但是当我在这里使用$ location.path(‘dashboard’)时,浏览器的URL被更改,但该页面没有加载。当使用ctrl R刷新I页面或单击浏览器的刷新图标时,加载适当的页面。 $http.post('/login',$scope.use
当用户输入正确的用户名和密码时,我想重定向到另一个位置。但是当我在这里使用$ location.path(‘dashboard’)时,浏览器的URL被更改,但该页面没有加载。当使用ctrl R刷新I页面或单击浏览器的刷新图标时,加载适当的页面。
$http.post('/login',$scope.userInfo)
        .success(function (data) {
            //Check if the authentication was a success or a failure
            //Successful POST here does not indicate success of authentication
            if (data.status === "authentication success") {

                //Proceed to load the dashboard for the user                    
                $location.path('/dashboard');

            } else if (data.status === "authentication error") {
                //Inform user of the error
                $scope.errorMessage = data.error;
                $scope.showErrorMessage = true;
            }

        })
        .error(function (error) {
            $scope.errorMessage = "Error while attempting to authenticate. Check  log.";
            $scope.showErrorMessage = true;

        });
    };

}]);
你试过使用$ scope吗?例如。:
if(!$scope.$$phase) $scope.$apply()

这种简短的方法也很方便:

https://github.com/yearofmoo/AngularJS-Scope.SafeApply

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读