angular-file-upload - 如何使drop zone可点击?

时间:2015-07-24 10:21:07

标签: file-upload angular-file-upload

使用nv-file-upload(https://github.com/nervgh/angular-file-upload)如何使放置区也可以作为可选择文件的可点击元素?添加{{nv-file-select}}似乎不起作用。

1 个答案:

答案 0 :(得分:3)

答案是你不能,在该插件中没有办法做到这一点,但我使用一个简单的解决方案来解决这类问题。在dragNdrop标记内添加ng-click并调用您的函数:

<div nv-file-drop="" uploader="upload" ng-click="launchFilePicker()">
 <div class="drop-box" ng-show="upload.isHTML5" uploader="upload" nv-file-over="" over-class="dragover" filter="image/*,application/pdf">
   Drag a file here.
  </div>
</div>
<div ng-hide="upload.isHTML5"> <input id="fileDialog" type="file" nv-file-select uploader="upload"/><br/></div>

在控制器内部执行此操作:

$scope.launchFilePicker = function () {
  //$('#fileDialog').click(); //not angular way
  angular.element('#fileDialog').trigger('click'); //angular way
};

我希望这有帮助。