3
I am developing an application with angular and I call a webservice that returns me a JSON and I wanted to know how to update this Json from time to time with angular, someone could give me a help?
3
I am developing an application with angular and I call a webservice that returns me a JSON and I wanted to know how to update this Json from time to time with angular, someone could give me a help?
4
Use the service $interval
.
It is equivalent to API window.setInterval
, but dedicated to using Angularjs (remember that Angular needs to update the view when the model is changed).
The use of this service is quite simple:
interval = $interval(fn, 1000, 0, true);
Description of parameters:
$apply
when the shot is finished (default).In the first parameter fn
, you should call the Web Service, probably using the service $http
.
Browser other questions tagged javascript json angularjs
You are not signed in. Login or sign up in order to post.
I can pass the function that does this in this parameter fn?
– Leonardo Villela
Yes. Just be careful that if it needs some parameter, you will have to create a wrapper without parameters, or modify the function so that it no longer needs the parameter.
– Vinícius Gobbo A. de Oliveira