Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/23.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 如何基于角度$timeout调用事件?_Javascript_Angularjs - Fatal编程技术网

Javascript 如何基于角度$timeout调用事件?

Javascript 如何基于角度$timeout调用事件?,javascript,angularjs,Javascript,Angularjs,我有实时日志,所以我在屏幕上添加了暂停/恢复实时流媒体的按钮,如果用户暂停实时日志120秒后恢复,所以,在正常情况下,如果用户暂停日志,它将在120秒内恢复,但如果用户在120秒内通过单击“恢复”按钮恢复,则在120秒后,它将再次暂停日志,而不需要用户与按钮交互。知道我在哪里实现了错误的代码吗 main.html <span class="serverConnectInfo" ng-if="enableLiveRecording === true"> <button typ

我有实时日志,所以我在屏幕上添加了暂停/恢复实时流媒体的按钮,如果用户暂停实时日志120秒后恢复,所以,在正常情况下,如果用户暂停日志,它将在120秒内恢复,但如果用户在120秒内通过单击“恢复”按钮恢复,则在120秒后,它将再次暂停日志,而不需要用户与按钮交互。知道我在哪里实现了错误的代码吗

main.html

<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 = [];
            })();
        }
    }