I have a fragment of my view that simply displays a loading indicator.
Html:
<span class="app-loading-container">
<span class="app-loading-animation" ng-show="loading"></span>
</span>
When I initially load the page, the span is visible. However, when I call my refresh method, the loading variable changes but the span does not show. Is there something I missed to trigger the span to display?
Controller:
app.controller('SavedSearchesCtrl', ['$scope', '$filter', '$window', 'lookupService', 'savedSearchesService',
function($scope, $filter, $window, lookupService, savedSearchesService) {
$scope.loading = true;
$scope.items = [];
$scope.alerts = [];
function getSavedSearches() {
savedSearchesService.getSavedSearches()
.success(function(data) {
$scope.items = data;
$scope.search();
})
.error(function(error) {
$scope.alerts.push({ type: 'error', msg: 'Unable to load saved searches data: ' + error.message });
});
$scope.loading = false;
}
$scope.refreshClick = function () {
$scope.loading = true;
savedSearchesService.refreshSavedSearches()
.success(function(data) {
$scope.items = data;
$scope.search();
$scope.alerts.push({ type: 'success', msg: 'Successfully refreshed saved searches data.'});
})
.error(function(error) {
$scope.alerts.push({ type: 'error', msg: 'Unable to refresh saved searches data: ' + error.message });
});
$scope.loading = false;
};
$scope.deleteClick = function(id) {
if (confirm("Delete this search? There's no undo...")) {
savedSearchesService.deleteSavedSearch(id)
.success(function () {
for (var i = 0; i < $scope.items.length; i++) {
var savedSearch = $scope.items[i];
if (savedSearch.SavedSearchKey === id) {
$scope.items.splice(i, 1);
$scope.search();
$scope.alerts.push({ msg: "Deleted saved search! Refreshing list." });
break;
}
}
})
.error(function (error) {
$scope.alerts.push({ type: 'error', msg: 'Unable to delete saved search: ' + error.message });
});
}
};
getSavedSearches();
}]);
I omitted some parts of the controller in this post, so it might not work if pasted directly into your IDE.
Thank you, Stephen