angularjs – Angular js Div只显示3秒钟

前端之家收集整理的这篇文章主要介绍了angularjs – Angular js Div只显示3秒钟前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在角度js是新的。我做了div隐藏和显示。只是我想知道如何隐藏或显示div 3秒钟。
这里我附上我使用的代码

HTML代码

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

角js代码

$scope.loginAlertMessage = true;

    $scope.forgotPassword = function () {
         $scope.loginAlertMessage=false;    
    };
在控制器中注入 $timeout service,并使用它来取消设置loginAlertMessage。
app.controller('MyController',function ($scope,$timeout) {
    $scope.loginAlertMessage = true;

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

    // ...
  }

猜你在找的Angularjs相关文章