I've got the following piece of code:
launch.controller('HeaderController', ['$scope', '$state','$timeout', function($scope, $state, $timeout){
$scope.reloading = false ;
$scope.reload = function(){
$scope.reloading = true;
$state.reload();
$timeout(function(){
$scope.reloading = false;
$scope.$apply()
}, 2000);
}
}]);
And the following template:
<img src="assets/img/refresh.svg" ng-class="{'reloading': reloading == true}">
When I do not use $scope.reload()
, it is perfectly reflected in the view. However, as soon as I use the function, the view doesn't recognize the boolean being changed.
I've checked whether the function is running at all, and it does; Adding a console.log
after $state.reload()
works just fine.
Also the view actually does doe a reload of the data.
What's the problem here..?