Dropzone becomes inactive when used in AngularJS ng-view -
i have controller displays images via template passed through ng-view , runs smoothly. have dropzone , running , working smoothly. however, add dropzone template dropzone no longer active. displays (the zone isn't clickable unless manually add dz-clickable, still nothing).
i add dropzone in ng-include above area , have hidden when template looking elsewhere have heard ng-include uses more processor ng-view prefer keep together.
i have seen there dropzone angularjs directive have not managed merge controller gets placed ng-view or if successful?
here directive:
(function(){ angular.module('dropzone', []) .directive('dropzone', function() { return function(scope, element, attrs) { element.dropzone({ url: "/upload", maxfilesize: 100, paramname: "uploadfile", maxthumbnailfilesize: 5, init: function() { scope.files.push({file: 'added'}); // here works this.on('success', function(file, json) { }); this.on('addedfile', function(file) { scope.$apply(function(){ alert(file); scope.files.push({file: 'added'}); }); }); this.on('drop', function(file) { alert('file'); }); } }); } }); }());
and here current controller:
(function() { 'use strict'; angular .module('app') .controller('customcontroller', customcontroller); customcontroller.$inject = ['api']; function customcontroller(api) { var vm = this; api.getdesigns() .then(function(data) { vm.designs = data; }); } }());
found own answer. rather adding dropzone hard coded template programmatically added dropzone within controller scope function using :
var mydropzone = new dropzone("div#myid", { url: "/file/post"});
Comments
Post a Comment