I have the following problem. I have a modal that uses a directive to which two callback functions are passed and which, when I open the modality for the first time, works perfectly. The problem comes when I close the modal and reopen it. The error appears in the console:
Invalid Isolate Scope Definition
Invalid {3} for directive 'dropZone'. Definition: {... NaNd: '021' ...}
Here the code of the directive:
moduloDirectivas.directive('dropZone',[
function(){
return config = {
restrict: "A",
scope: {
callbackUpload: '&callbackUpload',
callbackBeforeUpload: '&callbackBeforeUpload'
},
template:'<label class="drop-zone">'+
'<input type="file" id="fileinput" />'+
'<div ng-transclude></div>'+ // <= transcluded stuff
'</label>',
transclude: true,
replace: true,
require: '?ngModel',
link: function(scope, element, attributes, ngModel){
var upload = element[0].querySelector('input');
upload.addEventListener('drop', uploadFileSelect, false);
upload.addEventListener('change', uploadFileSelect, false);
config.scope = scope;
}
}
function uploadFileSelect(e) {
e.stopPropagation();
e.preventDefault();
config.scope.callbackBeforeUpload({estado: true});
var file = e.dataTransfer ? e.dataTransfer.files: e.target.files;
file = file[0];
var reader = new FileReader();
reader.onload = (function(file) {
return function(e) {
var data = e.target.result;
var objParameters = {
data: data,
nombreFichero: file.name,
tamanio: file.size
};
config.scope.callbackUpload({data: objParameters});
angular.element("#fileinput").val(null);
config.scope.callbackBeforeUpload({estado: false});
}
})(file);
reader.readAsDataURL(file);
}
}
]);
Let's see if you can think of what may be happening. Thanks.