简体   繁体   中英

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

This is the HTML code:

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

And this is jQuery code, which hides the button when clicked and then shows it after 5 seconds. I would like to code this in 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);
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM