Angularjs: Directive addEventListener Error -
i have created directive handle file upload wit uploadifive. upload module called on opening of modal window. first time call modal window works correctly. if open modal window again receive following error.
cannot call method 'addeventlistener' of undefined
i new if don't have enough information trouble shoot let me know else needed.
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 -->
directive
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 problem'); }, 'onupload': function() { } }); } }; });
controller
var myapp = angular.module('myapp',['ui.bootstrap', 'ui.sortable']);
function imagegalleryctrl ($scope, images, clients, galleries, 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 table $scope.getgallery = function(id) { //set gallery id scope $scope.galleryid = id; //open 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 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; }); };
any insight on great help. thanks
Comments
Post a Comment