Skip to content

Instantly share code, notes, and snippets.

@Julianhm9612
Created February 6, 2025 15:18
Show Gist options
  • Save Julianhm9612/eb1adc793ae0b92928a86dac3ccf6f91 to your computer and use it in GitHub Desktop.
Save Julianhm9612/eb1adc793ae0b92928a86dac3ccf6f91 to your computer and use it in GitHub Desktop.
Timer in minutes
$scope.counter = angular.copy($scope.datos.tiempoExpiracion * 60000);
function countdown() {
$scope.onTimeout = function () {
if ($scope.counter > 0) {
$scope.counter -= 1000;
const minutes = Math.floor(($scope.counter / 1000 / 60) % 60);
const seconds = Math.floor(($scope.counter / 1000) % 60);
vm.timeLeft = ('0' + minutes).slice(-2) + ':' + ('0' + seconds).slice(-2);
vm.mytimeout = $timeout($scope.onTimeout, 1000);
} else {
cvvQueryParent.showMessage('timeout');
}
};
vm.mytimeout = $timeout($scope.onTimeout, 1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment