Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular js Div show only for 3 seconds

Tags:

angularjs

i am new in angular js. i done with div hide and show. just i want to know how to hide or show div for 3 seconds only. here i attaching my code which i used.

html code:

<div ng-hide="loginAlertMessage">Dynamic user feedback message comes here.</div>    
<a ng-click="forgotPassword()">Forgot Password?</a>

angular js code:

$scope.loginAlertMessage = true;

    $scope.forgotPassword = function () {
         $scope.loginAlertMessage=false;    
    };
like image 849
HD.. Avatar asked Dec 10 '13 08:12

HD..


1 Answers

Inject the $timeout service in the controller and use it to unset loginAlertMessage.

app.controller('MyController', ['$scope', '$timeout', function($scope, $timeout) {
   $scope.loginAlertMessage = true;

   $scope.forgotPassword = function() {
      $scope.loginAlertMessage = false;
      $timeout(function() {
         $scope.loginAlertMessage = true;
      }, 3000);
   };

   // ...
}]);
like image 85
musically_ut Avatar answered Sep 21 '22 10:09

musically_ut