angularJs 页面定时刷新


页面定时刷新并在页面离开时停止自动刷新

var autoRefresh;
        //自动刷新
        autoRefresh = $interval($scope.loadData, 60000);
        //停止自动刷新
        $scope.stopAutoRefresh = function () {
            if (autoRefresh) {
                $interval.cancel(autoRefresh);
                autoRefresh = null;
            }
        };

        //切换页面时停止自动刷新
        $scope.$on('$routeChangeStart', function (angularEvent, current, previous) {
            $scope.stopAutoRefresh();
        });

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM