Created
February 15, 2016 14:01
-
-
Save IOExceptional/0bcf38835638cce60cba to your computer and use it in GitHub Desktop.
There's something that behaves strangely in this code, what's wrong? Tip: Mutable variables and closures.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var doStuff = function($scope) { | |
var model = []; | |
var items = $scope.items; | |
for(var i = 0; i < items.length; i++) { | |
var source = items[i]; | |
doAsyncThings().then(function(newValue){ | |
model[i].src = newValue; | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment