我是角度js的新手.我完成了div hide和show.只是我想知道如何隐藏或显示div仅3秒.在这里我附上我使用的代码.
HTML代码:
<div ng-hide="loginAlertMessage">Dynamic user feedback message comes here.</div>
<a ng-click="forgotPassword()">Forgot Password?</a>
Run Code Online (Sandbox Code Playgroud)
角度js代码:
$scope.loginAlertMessage = true;
$scope.forgotPassword = function () {
$scope.loginAlertMessage=false;
};
Run Code Online (Sandbox Code Playgroud)
mus*_*_ut 37
在控制器中注入$timeout服务并使用它来取消设置loginAlertMessage.
app.controller('MyController', ['$scope', '$timeout', function($scope, $timeout) {
$scope.loginAlertMessage = true;
$scope.forgotPassword = function() {
$scope.loginAlertMessage = false;
$timeout(function() {
$scope.loginAlertMessage = true;
}, 3000);
};
// ...
}]);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
34385 次 |
| 最近记录: |