html秒表

html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>秒表title>
    <script src="dsadas/jquery-3.2.1.js">script>
    <script src="dsadas/angular1.4.6.min.js">script>
head>
<body ng-app="myApp" ng-controller="myController">
<span ng-bind="clock">span>
<button ng-bind="butn" ng-click="clocker()">button>
<script>
    var myApp=angular.module("myApp",[]);
    var controller=myApp.controller("myController",function ($scope) {
       $scope.clock=0;
       $scope.butn="开始";
       var timer;
       $scope.clocker=function () {
           if ($scope.butn == "开始") {
               $scope.butn = "继续";
               timer = setInterval(function () {
                   $scope.$apply($scope.clock--);
               }, 1000);
           }
           else{
               $scope.butn="开始";
               clearInterval(timer)
               }
       };
    });
script>
body>
html>

你可能感兴趣的:(html秒表)