我在角度js是新的。我做了div隐藏和显示。只是我想知道如何隐藏或显示div 3秒钟。
这里我附上我使用的代码。
这里我附上我使用的代码。
<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); }; // ... }