Damian Hetman Damian Hetman - 1 year ago 116
AngularJS Question

Ionic Interval error - TypeError: fn is not a function

I need help with my app. I tried to refresh function every 5 seconds. Console shows "TypeError: fn is not a function". This is my code:

$scope.getItems = function (){
$scope.news = res;
.error(function(data, status) {


$interval($scope.getItems(), 5000);

Answer Source

For an interval, you have to pass the function, in this case your executing the function directly and pass the return value to $interval (which is undefined).

So change your code to this and it should work! :)

 $interval($scope.getItems, 5000);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download