1
My Angularjs page displays a table with data coming from a JSON. What I want is that the table is updated from time to time, because the data is updated according to the second and I show only the last 10.
<tr ng-repeat="linha in linhas">
<td ><abbr title="{{linha.descricao}}"> <a href=xxx.php?id_chamado={{linha.chamado}}>{{linha.chamado}}</a> </abbr> </td>
<td >{{linha.data}}</td>
<td >{{linha.nome}}</td>
<td >{{linha.acao}}</td>
<td >{{linha.cliente}}</td>
<td ><span class="label label-success">{{linha.sistema}}</span></td>
</tr>
Is there any simple way to reach this goal ?
My controller, everything works perfect in the page load. I just don’t know how to re-invoke this function inside the controller.
// JavaScript Document
var app = angular.module('sadApp', []);
app.controller('sadCtrl', function ($scope, $http) {
$http.get('http://192.168.0.14/a/historicochamadologlidosJson.php').
success(function(data, status, headers, config) {
$scope.linhas = data;
})
});
I’ve tried this code here:
angular.element(document.getElementById('MainWrap')).scope().$apply();
where Mainwrap is the id of div:
<div ng-controller="sadCtrl" id="MainWrap">
Query the data every X milliseconds, and update the callback
linhas
on your model. I imagine that a part of it is already done, I don’t understand exactly where you are having difficulties.– bfavaretto
The query is in the controller, I don’t know how to invoke it again, because Angular already automatically invokes when the page is loaded.
– FernandoNomellini
Can include relevant parts of the Controller in the questions, please?
– bfavaretto
OK - include the controller in the question. and what I’ve tried to do to invoke again
– FernandoNomellini