<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>
时间: 2024-10-11 23:47:13