angular-file-upload - how to make drop zone clickable?

隐身守侯 提交于 2019-12-06 14:47:46

问题


Using nv-file-upload (https://github.com/nervgh/angular-file-upload) how can I make the drop zone act also as a clickable element to select files? Adding {{nv-file-select}} does not seem to work.


回答1:


The answer is that YOU CANT, there is no way to do this inside that plugin but i use a simple solution for this kind of problems. Add a ng-click inside your dragNdrop tag and call your function:

<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>

And inside your controller you do this:

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

I hope this help.



来源:https://stackoverflow.com/questions/31608032/angular-file-upload-how-to-make-drop-zone-clickable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!