0

我创建了一个指令来处理文件上传和Uploadifive。在打开模式窗口时调用上传模块。我第一次调用模态窗口时一切正常。如果我再次打开模式窗口,我会收到以下错误。

Cannot call method 'addEventListener' of undefined 

我是新手,所以如果我没有足够的信息来解决这个问题,请告诉我还需要什么。

HTML

<div class="row">
<div class="span5">
    <h2>Upload New Image Gallery</h2>

    <form name="frm_upload" action="">
        <div class="control-group">
            <input image-uploadifive="{{galleryID}}" galleryid="{{galleryID}}" name="file_upload" type="file" multiple="true">
        </div><!-- /control-group -->
    </form>
    <div id="imageGallery_queue"></div>
</div><!-- /span5 -->

指示

    myApp.directive('imageUploadifive', function ()
{
    return {
        restrict: 'A',
        link: function(scope, element, attrs, controllers)
        {
            var id = scope.galleryID;

            $(element).uploadifive({
                'uploadScript'  : '/beta/images/upload',
                'buttonClass'   : 'uploadifive-button btn btn-primary',
                'queueID'       : 'imageGallery_queue',
                'buttonText'    : 'Select Files',
                'fileSizeLimit' : 500,
                'formData' : {
                    'galleryID' : id
                },
                'onError': function(errorType)
                {
                    alert('There was a problem');
                },
                'onUpload': function()
                {
                }
            });
        }
    };
});

控制器

var myApp = angular.module('myApp',['ui.bootstrap', 'ui.sortable']);

功能 imageGalleryCtrl ($scope, 图像, 客户, 画廊, createGal) { $scope.galleryMaster = {};

$scope.tabs = [
    { title:"Home", content:"/beta/application/views/images/uploader/create.html", active: true },
    { title:"Upload", content:"/beta/application/views/images/uploader/upload.html"},
    { title:"Edit", content:"/beta/application/views/images/uploader/edit.html"}
];

//close modal
$scope.close = function ()
{
    $scope.imageUploader = false;
};

//get gallery info on click from table
$scope.getGallery = function(id)
{
    //set gallery ID to scope
    $scope.galleryID = id;

    //open the modal
    $scope.imageUploader = true;

    //get gallery information
    $scope.galleryCollection = galleries.getGallery(id);

    $scope.galleryCollection.then(function(galleries){
        $scope.gallery = galleries.thisGal;
    });

    //get clients
    $scope.clientCollection = clients.getClients();

    $scope.clientCollection.then(function(clients){
        $scope.clients = clients.clients;
        $scope.clientList = $scope.gallery.client;
    });
};

$scope.tabName = function(name)
{
    if(name == 'Edit'){
        //get all the images 
        $scope.imgCollection = images.getImages($scope.galleryID);

        $scope.imgCollection.then(function(images){
            $scope.images         = images.thisGal_images;
            $scope.imageSortOrder = 'orgName';
        });
    }
};

$scope.newGallery = function()
{
    //open modal
    $scope.imageUploader = true;
    //create gallery
    $scope.newGallery = createGal.createGal();
    $scope.newGallery.then(function(createGal){
        $scope.galleryID = createGal.created_id;
    });
};

对此的任何见解都会有很大帮助。谢谢

4

0 回答 0