Javascript 如何基于角度$timeout调用事件?
我有实时日志,所以我在屏幕上添加了暂停/恢复实时流媒体的按钮,如果用户暂停实时日志120秒后恢复,所以,在正常情况下,如果用户暂停日志,它将在120秒内恢复,但如果用户在120秒内通过单击“恢复”按钮恢复,则在120秒后,它将再次暂停日志,而不需要用户与按钮交互。知道我在哪里实现了错误的代码吗 main.htmlJavascript 如何基于角度$timeout调用事件?,javascript,angularjs,Javascript,Angularjs,我有实时日志,所以我在屏幕上添加了暂停/恢复实时流媒体的按钮,如果用户暂停实时日志120秒后恢复,所以,在正常情况下,如果用户暂停日志,它将在120秒内恢复,但如果用户在120秒内通过单击“恢复”按钮恢复,则在120秒后,它将再次暂停日志,而不需要用户与按钮交互。知道我在哪里实现了错误的代码吗 main.html <span class="serverConnectInfo" ng-if="enableLiveRecording === true"> <button typ
<span class="serverConnectInfo" ng-if="enableLiveRecording === true">
<button type="button" class="btn btn-primary btn-md" ng-click="stopLiveEvent()"><span class="glyphicon glyphicon-pause"></span>pause</button>
</span>
<span class="serverConnectInfo" ng-if="enableLiveRecording === false">
<button type="button" class="btn btn-primary btn-md" ng-click="stopLiveEvent()"><span class="glyphicon glyphicon-play"></span>resume (in {{counter}}s)</button>
</span>
$scope.enableLiveRecording是否以true
或false
开头?$scope.enableLiveRecording是否以true
开头
function resetTimer(){
$scope.counter = 120;
}
// resetTimer();
$scope.onTimeout = function(){
$scope.counter--;
if($scope.counter > 0){
var mytimeout = $timeout($scope.onTimeout,1000);
}
if($scope.counter === 0){
$scope.stopLiveEvent();
resetTimer();
}
}
$scope.stopLiveEvent = function(){
$scope.enableLiveRecording = !$scope.enableLiveRecording;
if($scope.enableLiveRecording === false){
resetTimer();
toastr.warning('stop showing live event!');
$scope.onTimeout();
}
if($scope.enableLiveRecording === true){
toastr.info('start showing live event!');
(function () {
$scope.event = $scope.event.concat(tempStoreEvent);
tempStoreEvent = [];
})();
}
}