Angular js $ Interval奇怪的行为 - Firefox Chrome

时间:2016-05-06 16:15:22

标签: javascript angularjs google-chrome firefox intervals


我想在Angular Controller中每秒检索一个Json对象。 我的方法是使用$ interval,它实际上是有效的。
但是在

Google Chrome - 我的间隔时数约为每秒200次 Safari - 与chrome相同的行为 Firefox - 根本没有任何事情发生,count = 0

来自财务主任的代码:

(function(){

    var app = angular.module('timeDB',[])

    app.controller('listUserSupervisorController', ['$scope','$http','$interval', function($scope, $http, $interval){
        var count = 0;
        $interval(function(){
            $http.get('json/listUsers').then(function(res){
                $scope.userList = res.data;
                console.log("interval: "+count);
                count += 1;
            }), 1000
        });
    }]);

})(); 

Angular Version:1.5.5
Firefox版本:45.0.2
谷歌浏览器版本:50.0.2661.94

1 个答案:

答案 0 :(得分:2)

你把1000放在错误的地方......它应该是1级,在大括号之后。

相关问题