I'm learning AngularJS.
What I want to do is execute a method in a for loop with $timeout.
Here is example:
for(var i = 0; i < 10; i++) {
$timeout(function(i) {
someMethod(i);
}, 1000);
}
function someMethod(i) {
console.log('Executed : ', i);
}
But I cannot pass variable 'i'. How can I achieve this? Also, I'd like to know how to solve this problem with Angular $interval() as well.
Thanks!