Angular js Div show only for 3 seconds

angularjs

Solution

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);
   };

   // ...
}]);

Problem

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; }; ```

Original source