scope not found second time fileuploadchange, jquery-file-upload angularjs
-
30-06-2022 - |
Question
i am using jquery file upload with angular and it works great. I added my own callback on fileuploadchange, so when a user selects a different file, u get a callback. The upload form is in a overlay, that i close when the user is done. When a user wants to upload another image (that's where i use it form), the fileuploadchange reports a error
TypeError: data.scope is not a function
var scope = data.scope();
The line it is refering to
add: function (e, data) {
if (e.isDefaultPrevented()) {
return false;
}
var scope = data.scope(); <----------------------------------
data.process(function () {
return scope.process(data);
}).always(
I don't know why it is giving this error. When i console.log the data variable, the second time it is missing .scope() but i have no clue why.
Anyone got a suggestion? Thanks in advance!
-- additional info ---
The controller is set in the ng-view
<form id="fileupload" action="/api/profile/picture" method="POST" enctype="multipart/form-data" data-ng-controller="DemoFileUploadController" data-file-upload="options" data-ng-class="{'fileupload-processing': processing() || loadingFiles}" class="avatar">
and in the controller i have the following options
$scope.options = {
url: '/api/userprofile/' + $rootScope.User.UserId + '/avatar/',
type: 'POST'
};
The directives are a exact copy of the once in github, provided by blueimp, https://github.com/blueimp/jQuery-File-Upload/blob/master/js/jquery.fileupload-angular.js
No correct solution