is there way use 1 instance of angulars $timeout?
for example, there code:
for(i=0; i<10; i++) { $timeout(function() { console.log('test'); }, 2000); }
evaluating code, angular return 10 console messages after 2 seconds. there way 1 last message?
edit: loop example, dont know number of cycles, need last one.
thanks
i think mean everythime new message set, have use timeout?
var timeout; (var = 0; < 10; i++) { if (timeout) timeout.cancel(); timeout = $timeout(function() { console.log("test"); }, 2000); }
or, if need someting on last 1 of loop:
var somelength = 83; (var = 0; < somelength; i++) { if (i === somelength - 1) { $timeout(function() { console.log("test"); }, 2000); } }
Comments
Post a Comment