I'm developing an application with angular and I'm calling a webservice that returns me a JSON and wanted to know how I can update this Json from time to time with angular, could anyone give me a help?
I'm developing an application with angular and I'm calling a webservice that returns me a JSON and wanted to know how I can update this Json from time to time with angular, could anyone give me a help?
Use the $interval
service.
It is equivalent to window.setInterval
API, but dedicated to use AngularJS (remember that Angular needs to refresh the view when the model is changed).
The use of this service is quite simple:
interval = $interval(fn, 1000, 0, true);
Parameters description:
$apply
service when firing is finished (default). In the first parameter fn
, you should call the Web Service, probably using the $http
service.