首页 > Web开发 > 详细

AngularJS - 定时器 倒计时例子

时间:2016-04-05 00:19:44      阅读:4329      评论:0      收藏:0      [点我收藏+]
<body>
    <div ng-app="myApp">
        <div ng-controller="firstController">
          <input type="button" ng-value ="text" ng-disabled="isDisable"/>
 
           <input type="text" value="{{text}}" ng-readonly="isDisable" />

            <input type="checkbox" value="{{text}}" ng-checked="isDisable" />
        </div>
    </div>
    <script type="text/javascript">
        var app = angular.module("myApp", []);

        app.controller(‘firstController‘, [‘$scope‘, ‘$interval‘, function ($scope, $interval) {
          
            $scope.n = 10;
            $scope.text = $scope.n + "秒";
            $scope.isDisable = true;

            var time = $interval(function () {

                $scope.n--;
                $scope.text = $scope.n + "秒";
                if ($scope.n == 0)
                {
                    $interval.cancel(time);
                    $scope.isDisable = false;
                    $scope.text = "可以点击";
                }

            },1000);
          
        }]);
         
    </script>

</body>

 

AngularJS - 定时器 倒计时例子

原文:http://www.cnblogs.com/MarchThree/p/5353255.html

(1)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!