'Don't make functions within the loop' + 'file is not defined' #766

dansurfs opened this Issue May 27, 2015 · 2 comments


None yet

3 participants


Hey there,

I put in the controller code exactly as it is in the demo and JsHint gives me back 'Don't make functions within a loop.'
If I put the functions outside of the loop (besides perhaps breaking the intended functionality), I get back 'file is not defined.'

Have you heard of this happening before? Can you show how to fix this? I've seen some stuff on the web about it but don't know what to change within the controller.

Thanks a bunch.

@danialfarid danialfarid pushed a commit that referenced this issue Jun 4, 2015
Danial Farid Fixed #783 #764 #777 #766 #763 #761 #721 #687 #650 #710 #784 #768 #789 39fa784

Should be fixed in 5.0.0

@danialfarid danialfarid closed this Jun 4, 2015
deegale commented Jul 6, 2015

I know this is closed, but I was still getting "Don't make functions within the loop" error message from JsHint. I had made a batch upload page, following the example code in the readme. Here is what I needed to change to avoid the error JsHint warning. I'm adding this code here in case someone else googles and comes across this post like I did:

  $scope.upload = function (files) {
      if (files && files.length) {
        for (var i = 0; i < files.length; i++) {
          var file = files[i];
          var studentId = file.name.split('.')[0];
            url: 'admin/update/photo',
            fields: { 'id': studentId },
            file: file

  function uploadGood (data, status, headers, config) {
    // Handle the success

  function uploadBad (data, status, headers, config) {
     // Handle the error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment