I find myself doing this quite frequently, but I'm unsure if it's actually effective. How can I verify that it's working as intended? And if it's not, what is a more reliable way to cancel a timeout after it has finished?
var delay = $timeout(function() {
for (i = 0; i < allHighlightedEls.length; i += 1) {
//... implementing some changes
}
}, 1000)
.then(function() {
$timeout.cancel(delay);
});