Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/391.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在AngularJs间隔中悬停和暂停时间?_Javascript_Jquery_Html_Css_Angularjs - Fatal编程技术网

Javascript 如何在AngularJs间隔中悬停和暂停时间?

Javascript 如何在AngularJs间隔中悬停和暂停时间?,javascript,jquery,html,css,angularjs,Javascript,Jquery,Html,Css,Angularjs,在我的UI中有一段时间,其中的时间使用AngularJS间隔不断更新。甚至毫秒也在连续运行。记住这一点,当我在上面悬停时,可以暂停时间。非常感谢你的帮助。下面是代码 用户界面的图像 html <div class="container"> <div class="row "> <div class="col-lg-12 text-center" ng-app="myApp" ng-controller="myCtrl"> <h3 ><

在我的UI中有一段时间,其中的时间使用AngularJS间隔不断更新。甚至毫秒也在连续运行。记住这一点,当我在上面悬停时,可以暂停时间。非常感谢你的帮助。下面是代码

用户界面的图像

html

 <div class="container">
 <div class="row ">
 <div class="col-lg-12 text-center" ng-app="myApp" ng-controller="myCtrl">
<h3  ><b id="thetime">{{theTime| date:'hh:mm:ss sss a'}}</b></h3>
</div>
</div>
</div>

ng mouseover
ng mouseleave中的停止间隔功能

    $scope.startInterval = function(){
         $scope.flag = $interval(function(){
                        $scope.theTime = new Date();
                    }, 6);
    }

    $scope.stopInterval= function(){
       if($scope.flag)
       $interval.cancel($scope.flag);
    }
    $scope.startInterval();

ng mouseover
ng mouseleave中的停止间隔功能

    $scope.startInterval = function(){
         $scope.flag = $interval(function(){
                        $scope.theTime = new Date();
                    }, 6);
    }

    $scope.stopInterval= function(){
       if($scope.flag)
       $interval.cancel($scope.flag);
    }
    $scope.startInterval();

谢谢你的回复……但这不起作用……时间本身停止了移动。它仍然停止。哇!!这真是太棒了。非常感谢,伙计。谢谢你的回应。但是那不起作用。时间本身停止了移动。它仍然停止。哇!!这真是太棒了。非常感谢,伙计。