I am feeling a bit disappointed with my countdown function:
/* countDowner */
var countDown = 5;
function countDowner() {
if (countDown < 0) {
$("#warning").fadeOut(2000);
var countDown = 0;
return; // exit
} else {
$scope.countDown_text = countDown; // update scope
setTimeout(countDowner, 1000); // repeat the loop
countDown--; // decrease by 1
}
}
$scope.countDown_text = countDown;
countDowner();
I added it to an AngularJS controller and it's causing issues with my code :/ There is an error, but it seems to be related to another part of the code. Everything works fine when I remove the countdown function. Can anyone help me figure out what's wrong with my countdown?