使用$interval()实现自动刷新数据

需要注意调用interval()参数内写 function(){},delay:

                autoRefresh = $interval(function (){
                    .........
                }, delay);
 //自动刷新,刷新间隔10min,离开页面则取消自动刷新
                var autoRefresh;
                autoRefresh = $interval(function (){
                    getData($scope.currentViewType,$scope.currentPeriod,$scope.statusFiler)
                }, 600000);

                $scope.stopAutoRefresh = function () {
                    if (autoRefresh) {
                        $interval.cancel(autoRefresh);
                        autoRefresh = null;
                    }
                };

                $scope.$on('$destroy', function (angularEvent, current,) {
                    $scope.stopAutoRefresh();
                });

你可能感兴趣的:(使用$interval()实现自动刷新数据)