Below is the code snippet that I am currently working with:
function initialize() {
var defer = $q.defer();
var deferTimer = $q.defer();
var cancelTimeout = $timeout(function() {
if (defer !== null) {
ctrlr.setProcessingParameters('XXX');
defer = ctrlr.openProgressBar();
deferTimer.resolve();
}
}, 1000);
deferTimer.promise.then(function() {
var cancelTimeout2 = $timeout(function() {
if (defer !== null) {
defer.resolve();
ctrlr.setProcessingParameters('Please Wait...');
defer = ctrlr.openProgressBar();
}
}, 4000);
});
//Process Backend service n resolbve defer....
}
// Cancel the $timeout service
$rootScope.$on('$destroy', function() {
logger.log("Cancelling timeout..");
if (cancelTimeout) {
$timeout.cancel(cancelTimeout);
cancelTimeout = null;
}
});
// Cancel the second $timeout service
$rootScope.$on('$destroy', function() {
logger.log("Cancelling timeout2..")
if (cancelTimeout2) {
$timeout.cancel(cancelTimeout2);
cancelTimeout2 = null;
}
});
I'm facing an issue where the loggers are not printing and the debugger doesn't seem to enter the $destroy
function. Any insights on what might be causing this would be greatly appreciated.