gpt4 book ai didi

javascript - Angularjs $location.path() 不重定向

转载 作者:行者123 更新时间:2023-11-28 00:39:33 24 4
gpt4 key购买 nike

为什么我使用 angular.js $location.path 时没有重定向到其他 URL?

.controller('CheckCtrl', function($scope, $localStorage, $location) {
$scope.check = function(){

if($localStorage.hasOwnProperty("accessToken") === true) {
alert("CheckCtrl logged in" + $localStorage.accessToken);
$location.path("/post-report");
}else{
alert("CheckCtrl not logged in" + $localStorage.accessToken);
$location.path("home.login");
}
};

})

尽管 $localStorage.hasOwnProperty 已经为 true,因为它包含来自 Facebook 的 token 。

我也尝试了$location.reload()但仍然没有运气。

最佳答案

使用这个:-

$location.path("/post-report").replace();
or
$location.path("/post-report");
if(!$scope.$$phase) $scope.$apply()

它将用新位置替换您当前的位置。

关于javascript - Angularjs $location.path() 不重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28102227/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com