Well I have a grid and it needs to be ALWAYS updated because it contains information that needs to be updated dynamically.
This grid is populated with a rest flame that returns me a json. I need the grid to be updated as soon as the json of the rest call has any changes.
In my case to treat the json data and put it on the grid I'm using AngularJS and populating with an ng-repeat. Today I'm getting the updates with a setInterval of 1 second ... but this is not cool, because if I have to put some checkbox on this grid, I will not be able to check because since it updates every 1 second I would always return to the FALSE state. / p>
Would you have any solutions? I do not know how the sites that "broadcast" football games work ... but it's more or less that way. I would like to know how they do to add or remove rows from the grid without having to refresh the grid or the entire scope.
My JS:
var app = angular.module("teste", []);
app.controller("GridController", ['$scope', '$http', function (ng,
$http) {
ng.locations = [];
setInterval(function() {
$http.get("http://testechamarest.com:18888/json").success(function
(dados) {
ng.locations = $.map(dados, function (dev) {
return dev;
});
}, 1000); ]);
New problem: When I modify the update time, for example: I put 3000 (3 secs) the page takes 3 seconds to open ... in the current case it is taking 1 sec to open. .. my logic in doing this must be all wrong ... but I do not know what I could improve on. :