$locationChangeStart 在 Firefox 中不工作

$locationChangeStart is not working in firefox

$scope.$on("$locationChangeStart", 函数(事件,下一个,当前){

        if (!$rootScope.isPopupOpen) {

            if ($rootScope.isUrlLoad) {

               window.location.reload();

            }
        }

        $rootScope.isUrlLoad = true;

    });

In other browser,i have no problem for loading..But in firefox it continuously loading.can anyone please suggest me?

您的问题可能与 $locationChangeStart 它甚至在您的页面第一次加载时被调用有关。

用一个标志简单地解决这个问题:

var firstTime = true;
$scope.$on("$locationChangeStart", function (event, next, current) {

    if(firstTime){
       firstTime = false;
       event.preventDefault();
       return;
    }

    if (!$rootScope.isPopupOpen) {

        if ($rootScope.isUrlLoad) {

           window.location.reload();

        }
    }
    $rootScope.isUrlLoad = true;
});