0
Hello, I am loading my view with a timer and each time the timer runs it does not clean the screen but adds the same items again. I’ve tried cache=false, window.Reload, state.Reload, state.go, but no results, my code:
lista = function () {
$http.post(G.URL + 'pagina.jsp')
.then(function (response) {
$scope.totalItens = response.data.records.length;
$scope.items = response.data.records;
$scope.counter = 1;
}, function (error) { $scope.items = "Não foi possível listar."; });
}
$interval(function () {
$scope.counter += 1;
if ($scope.counter > 59) {
$scope.counter = 1;
lista()
//$ionicHistory.clearCache([$state.current.name]).then(function () { $state.reload(); });
}
}, 1000);
$scope.$watch(function () { return $scope.d = { tempo: $scope.counter }; }, true);
Thank you in advance.
By his logic of
$interval
the user needs to wait 60 seconds to load the new list of$scope.items
.– user21448
You’ve seen if your Answer.data.Cords is coming right. If you’re putting $Scope. $apply(Function(){ $Scope.items = Response.data.Records; }); instead of $Scope.items = Response.data.Records; . If it doesn’t work, add your html to your question to see if there is something wrong.
– André Vicente
Thanks Never and André, I managed to solve using angular.extend($Scope and $timeout at the end and updated the variables on the screen as I needed, thanks for the attention.
– Luciano Coelho