I have a best practice question regarding showing/hiding an ajax loading animation while I/O is being performed. Currently, I am handling the animation using the following code:
JS
app.controller('MyController', function($scope, Resource) {
$scope.loading = true;
Resource.query(function(response) {
$scope.loading = false;
$scope.items = response;
});
});
HTML
<ul ng-controller="MyController">
<div ng-if="loading">
<img src="/assets/ajax-loader.gif">
</div>
<li ng-repeat="item in items">{{ item }}</li>
</ul>
Is this the best way to handle the showing/hiding of the ajax loader? I see some scalability issues as I start to add multiple modules and have to store a separate loading value for each.