0

Here is my case , I have an array :

var fileParamsArray=['fileThumbanilRetina','fileThumbanilNonRetine','fileThumbanilHdpi' ];

and in my view i have :

 <input type="file" name="fileThumbanilRetina" file-model="fileThumbanilRetina" />  
 <input type="file" name="fileThumbanilNonRetine" file-model="fileThumbanilNonRetine" />  
 <input type="file" name="fileThumbanilHdpi" file-model="fileThumbanilHdpi" /> 

in my angularJS controller i want to have something like $scope.fileThumbanilRetina but when try to append array index value to $scope . its not happening In my controller Here is my function :

   $scope.submitForm = function() {    
      var fileParamsArray = [
              'fileThumbanilRetina',
              'fileThumbanilNonRetine',
              'fileThumbanilHdpi' ];
      for(i=0;i<fileParamsArray.length;i++) {
          var file = $scope.fileParamsArray[i];
          console.log(file);
          //call to service function  
          fileUpload.uploadFileToUrl(file, uploadUrl,fileParamsArray[i]);
      }
   }

Please Help

6
  • have u defined $scope.fileParamsArray? Commented Oct 21, 2014 at 8:27
  • where is your controller code? post it in your question too. Commented Oct 21, 2014 at 8:28
  • If possible, create a fiddle and post the link. Commented Oct 21, 2014 at 8:32
  • @jai controller code added . Commented Oct 21, 2014 at 8:40
  • @user2717954 , Point is i just want name from that array and than access my scope modal of that name like $scope.fileThumbanilRetina Commented Oct 21, 2014 at 8:41

1 Answer 1

2

If I've understood your 'question' right...you want something like

for(var i ...)
var file = $scope[fileParamsArray[i]];
...
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.