美文网首页
使用$interval()实现自动刷新数据

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

作者: Whisper_X | 来源:发表于2019-04-17 19:19 被阅读0次

需要注意调用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()实现自动刷新数据

      本文链接:https://www.haomeiwen.com/subject/znkowqtx.html