I have the following code to display a progressbar:
var cancelTimeoutProcess = $timeout(function () {
if (defer !== null) {
vm.setProcessingParameters('No Message');
defer = vm.openProgressBar();
deferTimer.resolve();
}
}, 1000);
// cancel the $timeout service
$scope.$on('$destroy', function () {
if (cancelTimeoutProcess) {
$timeout.cancel(cancelTimeoutProcess);
cancelTimeoutProcess = null;
}
});
Wanted to confirm if this is the right way to launch a progressbar and destroy the timeout?