While creating my app in AngularJS (awesome framework!) I stuck in one task: how to show and hide hidden div (ng-show) after some action.
Detailed description: using AngularUI $modal service I'm asking if user wants to perform action, if yes, I run service to POST request via $http to send which item I want to delete. After it finished I want to show hidden div with information, that process has accomplished successfully. I created a simple service with $timeout to set div's ng-show and hide after some time but it doesn't update variable assigned to ng-show directive. Here is some code:
Controller for listing and deleting items
 $scope.deleteSuccessInfo = false; //variable attached to div ng-show
 $scope.deleteCluster = function(modalType, clusterToDelete) {
    modalDialogSrvc.displayDialog(modalType)
        .then(function(confirmed) {
            if(!confirmed) {
                return;
            }
            clusterDeleteSrvc.performDelete(itemToDelete)
                .then(function(value) {
                    //my attempt to show and hide div with ng-show
                    $scope.deleteSuccessInfo = showAlertSrvc(4000);
                    updateView(itemToDelete.itemIndex);
                }, function(reason) {
                    console.log('Error 2', reason);
                });
        }, function() {
            console.info('Modal dismissed at: ' + new Date());
        });
};
function updateView(item) {
   return $scope.listItems.items.splice(item, 1);
}
Part of service for deleting item
function performDelete(itemToDelete) {
    var deferred = $q.defer(),
        path = globals.itemsListAPI + '/' + itemToDelete.itemId;
    getDataSrvc.makeDeleteRequest(path)
        .then(function() {
            console.log('Item removed successfully');
            deferred.resolve({finishedDeleting: true});
        }, function(reason) {
            console.log('error ', reason);
            deferred.reject(reason);
        });
    return deferred.promise;
}
return {
    performDelete: performDelete
};
Simple service with $timeout to change Boolean value after some time
angular.module('myApp')
    .service('showAlertSrvc', ['$timeout', function($timeout) {
        return function(delay) {
            $timeout(function() {
                return false;
            }, delay);
            return true;
        };
    }]);
I tried $scope.$watch('deleteSuccessInfo', function(a, b) {...}) with no effect. How to apply false after some delay? Or maybe You would achieve this in other way?
Thank You in advance for any help!
 
     
     
    