0

Hi I am developing web application in angularjs. I am developing file upload module. I am doing it dynamically. I will get a list of files to be uploaded from api call. Once i get list i assign dynamically to scope variable of ng-repeat directive as below.

<div class="upload-button" ng-repeat="fileInput in fileInputs">
    <div ng-if="fileInput.Filepath == ''">
        <input type="file" file-data="{{fileInput.Filename}}" file-model="
        {{fileInput.Filename}}" id="file_input_id" required valid-file/>
    </div>
</div>

Suppose if i get 7 files from api then i will get 7 file upload controls. I want to make all 7 controls mandatory on submiting the form. May i know how this can be done? Any help would be appreciated. Thank you.

Vivz
  • 6,625
  • 2
  • 17
  • 33
Niranjan Godbole
  • 2,135
  • 7
  • 43
  • 90
  • Seems like there's no built in solution. Does something like this work for you? https://stackoverflow.com/questions/16207202/required-attribute-not-working-with-file-input-in-angular-js – itsmichaelwang Jul 20 '17 at 07:35
  • Thank you. that will work when there is one file. How to apply same directive when there are dynamically generated file controls? – Niranjan Godbole Jul 20 '17 at 07:39

1 Answers1

2

Maybe try using the ng-file-upload directive. this has everything that you need to upload files and easy to use. i've use this on all apps i developed.

check ng-file-upload github

redanesc
  • 325
  • 4
  • 14