angularjs – Angular js Div只显示3秒钟
发布时间:2020-12-17 08:09:29 所属栏目:安全 来源:网络整理
导读:我在角度js是新的。我做了div隐藏和显示。只是我想知道如何隐藏或显示div 3秒钟。 这里我附上我使用的代码。 html代码: div ng-hide="loginAlertMessage"Dynamic user feedback message comes here./div a ng-click="forgotPassword()"Forgot Password?/a
我在角度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); }; // ... } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |