我想在用户单击 recordLogs
时启动计时器方法并在用户点击 stopLogs
时重置计时器方法。根据 Angular 计时器文档,我们可以使用 timer-stop
和timer-clear
实现这些任务的方法,但我收到错误 start
和clear
当我从 Controller 调用它们时,计时器上未定义。有什么想法吗?
main.html
<div class="col-md-3">
<timer interval="1000">{{hours}} hour{{hoursS}}, {{minutes}} minute{{minutesS}}, {{seconds}} second{{secondsS}}.</timer>
</div>
Ctrl.js
$scope.stopLogs = function() {
$scope.timer-clear();
};
$scope.recordLogs = function() {
$scope.timer-start();
}
最佳答案
关于javascript - 如何从 Controller 启动和重置 Angular 计时器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39088229/