1

I have file upload and I can upload file then get controller value put in input hidden value because I will be post form.

HTML CODE

<input type="file" class="form-control" id="i_file5" file-model="process.step.file5" ng-file-select="onFileSelect($files5)" />
<input type="hidden" ng-model="{{files.name}}"/>

Controller Code

$scope.uploadResult = [];
        $scope.onFileSelect = function($files) {
            //$files: an array of files selected, each file has name, size, and type.
            for (var i = 0; i < $files.length; i++) {
                var $file = $files[i];
                $upload.upload({
                    url: 'lib/fileupload/',
                    file: $file,
                    progress: function(e){}
                }).then(function(response) {
                    // file is uploaded successfully
                    $timeout(function() {
                        $scope.uploadResult.push(response.data);
                        console.log($scope.uploadResult);
                    });
                }); 
            }
        }

1 Answer 1

2

I am assuming you have already specify controller in HTML. If not please implement as shown in below example. For ng-model you should not use {{ }} as you are binding the value not evaluating it.

<div ng-controller="files">
----
<input type="text" data-ng-model="files.name" style="display:none"/>

</div>
Sign up to request clarification or add additional context in comments.

2 Comments

agree.. modified my answer
Yes I agree with you.. Thanks :)

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.