【问题标题】:How to Integrate dynamic URL in angular dropzone directive如何在 angular dropzone 指令中集成动态 URL
【发布时间】:2016-08-21 18:30:29
【问题描述】:

我正在使用 https://github.com/vberbenetz/EasyUpload angularjs 文件上传代码。 这是角dropzone的链接--dropzone

我想为多个路径上传文件。如何为动态 url 配置 drozone 指令 这是放置区指令

appControllers.directive('dropzone', dropzone);
function dropzone(){
return function(scope, element, attrs) {


    var config = {
        url : "api/company/logo/1",--->i want this url dynamically
        maxFilesize: 100,
        paramName: "uploadfile",
        maxThumbnailFilesize: 10,
        parallelUploads: 1,
        autoProcessQueue: true
    };

    var eventHandlers = {
        'addedfile': function(file) {           
            scope.file = file;
            if (this.files[1]!=null) {
                this.removeFile(this.files[0]);
            }
            scope.$apply(function() {
                scope.fileAdded = true;
            });
        },

        'success': function (file, response) {
        }
    };

    dropzone = new Dropzone(element[0], config);

    angular.forEach(eventHandlers, function(handler, event) {
        dropzone.on(event, handler);
    });


    scope.processDropzone = function() {
        dropzone.processQueue();
    };

    scope.resetDropzone = function() {
        dropzone.removeAllFiles();
    }
}}

【问题讨论】:

    标签: angularjs dropzone.js


    【解决方案1】:

    指令代码:

        scope.processDropzone = function(url) {
            dropzone.options.url = url;
            dropzone.processQueue();
        };
    

    来自控制器:

        $scope.processDropzone("http://localhost:8080/my/custom/upload");
    

    【讨论】:

      猜你喜欢
      • 2015-07-21
      • 1970-01-01
      • 2017-07-25
      • 2019-07-05
      • 1970-01-01
      • 2018-11-14
      • 2014-12-09
      • 2017-11-18
      • 1970-01-01
      相关资源
      最近更新 更多