当点击按钮时隐藏按钮,然后在5秒后显示它

How to code this AngularJS hide the button when clicked and then show it after 5 seconds

本文关键字:按钮 5秒 然后 显示 隐藏      更新时间:2023-09-26

这是HTML代码:

<button id="btn_hide">Hide Me!</button>

这是jQuery代码,当点击按钮时隐藏按钮,然后在5秒后显示它。我想在AngularJS中编写这个代码。

$(document).ready(function() {
$('#btn_hide').click (function() {
        $(this).hide(5000,function () {
            $('#btn_hide').show(5000);
        });  
  });
});
<button id="btn_hide" ng-click="hide()" ng-hide="hidden">Hide Me!</button>
$scope.hide = function() {
    $scope.hidden = true;
    $timeout(function() {
        $scope.hidden = false;
    }, 5000);
};