Javascript 如何在AngularJs间隔中悬停和暂停时间?
在我的UI中有一段时间,其中的时间使用AngularJS间隔不断更新。甚至毫秒也在连续运行。记住这一点,当我在上面悬停时,可以暂停时间。非常感谢你的帮助。下面是代码 用户界面的图像 htmlJavascript 如何在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 ><
<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();
谢谢你的回复……但这不起作用……时间本身停止了移动。它仍然停止。哇!!这真是太棒了。非常感谢,伙计。谢谢你的回应。但是那不起作用。时间本身停止了移动。它仍然停止。哇!!这真是太棒了。非常感谢,伙计。