angularjs make a simple countdown

后端 未结 10 1543
别跟我提以往
别跟我提以往 2020-12-12 19:26

I would like make a countDown with Angular js. this is my code:

Html File

{{countDown}}
10条回答
  •  一整个雨季
    2020-12-12 19:59

    $scope.countDown = 30;
    var timer;
    $scope.countTimer = function () {
        var time = $timeout(function () {
             timer = setInterval(function () {
                 if ($scope.countDown > 0) {
                     $scope.countDown--;
                } else {
                    clearInterval(timer);
                    $window.location.href = '/Logoff';
                }
                $scope.$apply();
            }, 1000);
        }, 0);
    }
    
    $scope.stop= function () {
        clearInterval(timer);
        
    }
    

    IN HTML:

    
    
                     
                    
                  
    

提交回复
热议问题