I am working on the functionality to display a loader gif and data accordingly in Angular. I have tried using plain JavaScript setInterval code but it doesn't work for $scope.showLoader=true and $scope.showResult=true. The console.log('found the ...') statement works, but the first 2 statements (show hide) do not work. The loader keeps rotating and the data does not display. Do you think using angular $setTimeout would work instead?
$scope.showLoader = true;
$scope.showResult = false;
var timer = setInterval(function(){
if($scope.resultArray.length == 4) {
clearInterval(timer);
$scope.showResult = true; // doesn't work
$scope.showLoader = false; // doesn't work
console.log('found all search results'); // it works
}
},200);