$ locationChangeStart在firefox中不起作用

时间:2016-09-23 13:16:54

标签: angularjs ng-view on-location-changed

$ scope。$ on(“$ locationChangeStart”,function(event,next,current){

        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?

1 个答案:

答案 0 :(得分:1)

您的问题可能与$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;
});