0
  <input type="file" id="file" name="file" ng-show="attachFile" />
  <button type="button" ng-model="attach" ng-click="add()">Attach</button>

  <div class="panel panel-default" ng-show="displayAttachments">
    <div class="panel-heading">
      <h3 class="panel-title">Attachments</h3>
    </div>
    <div class="panel-body">
      <ul class="list-group">

        <li class="list-group-item">C:\fakepath\angularjs_tutorial.pdf</li>

        <li class="list-group-item">display file path using ng-repeat in this panel</li>

      </ul>
    </div>
  </div>

I have a button called attach that calls the add() function written in my controller, which enables the input of type file. The functionality is

  • Display the choose file button(input type=file) on clicking add
  • after choosing file, this choose file must disappear and attachment field appears
  • the path of the file must appear in the li tag of attachments field which i think can be done using ng-repeat
  • I must be able to upload another file by the above files and the path of this new file must appear below the path of already chosen file.

My controller has this code

$scope.attachFile = false;
$scope.displayAttachements = false;
$scope.add = function() {
  $scope.attachFile = true;
}
CozyAzure
  • 8,280
  • 7
  • 34
  • 52
Kiran Kumar
  • 127
  • 3
  • 14

1 Answers1

0

Check This Solution i think it will help since no binding for file type input attribute

Community
  • 1
  • 1
Theophilus Omoregbee
  • 2,463
  • 1
  • 22
  • 33
  • Yes, i checked this but i have to deploy this in production, cant have debug mode enabled there. So isn't there any alternative? There is one possible solution which is http://jsfiddle.net/marcenuc/ADukg/49/ , but am not sure how to include the MyCtrl.prototype.setFile in the same module myapp – Kiran Kumar Jul 13 '16 at 11:12
  • oh , he is using normal javascript function , since ng-change needs ng-model binding which is not available for file input. – Theophilus Omoregbee Jul 13 '16 at 16:40
  • https://github.com/danialfarid/ng-file-upload . check out this fiddle http://jsfiddle.net/danialfarid/maqbzv15/1118/ – Theophilus Omoregbee Aug 04 '16 at 12:23