[Solved] Issues with getting $timeout function to work


You can just use angular $timeout to achieve the wanted like this:

var timer;
$scope.isFooCollapsed = true;
$rootScope.$on("bagNotification", function() {
  $timeout.cancel(timer);
  $scope.isFooCollapsed = !$scope.isFooCollapsed;
  timer = $timeout(function() {
    $scope.isFooCollapsed = true;
  }, 3000);
});

We cancel the timeout each time with $timeout.cancel to prevent multiple hide/shows when button is clicked multiple times.

Plunkr: http://plnkr.co/edit/YbsCuicDiHVDGULwpap3?p=preview

3

solved Issues with getting $timeout function to work