我的应用需要帮助。我试着每5秒刷新一次功能。控制台显示“TypeError:fn不是函数”。这是我的代码:
$scope.getItems = function (){
$http.get('http://example.com/script.php')
.success(function(res){
$scope.news = res;
})
.error(function(data, status) {
console.log("Error");
})
.finally(function(){
$scope.$broadcast('scroll.refreshComplete');
});
}
$scope.getItems();
$interval($scope.getItems(), 5000);
答案 0 :(得分:2)
对于间隔,您必须传递函数,在这种情况下,您直接执行函数并将返回值传递给$ interval(未定义)。
所以将代码更改为此代码应该可以正常工作! :)
$interval($scope.getItems, 5000);