Currently, I am utilizing the yo:angular-fullstack
generator for developing my website. After a user registers on the site, an activation email is sent containing a verification link. Upon clicking the link, a message confirming successful activation is displayed along with a timeout redirecting to the home page. However, if the user clicks another link before the timeout completes, they are redirected to a different page while the timeout continues running in the background. After several seconds, the user is still directed back to the home page.
$scope.countdown = 10;
$scope.onTimeout = function() {
$scope.countdown--;
timer = $timeout($scope.onTimeout, 1000);
if ($scope.countdown === 0) {
$timeout.cancel(timer);
$location.path('/');
}
};
var timer = $timeout($scope.onTimeout, 1000);
I am unsure of how to effectively cancel the timer
when the user clicks on other links within the page.