angularjs - Is there any way to run a javascript function by a timer? -


i have app gets data web service. want know whether there way while app open not being used run function every few minutes.

basically, want check internet connectivity , check make sure web service up.

you can use setinterval or use settimeout.

setinterval works constant loop, can time 3 seconds , every second run code inside of setinterval so

setinterval(function() {     alert("hello");  }, 3000); 

settimeout works after specific amount of time has gone , runs code so

settimeout(function() {      alert("hello");  }, 3000); 

the timer in milliseconds 1000 = 1 second


Comments