Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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

share|improve this question
    
Are you using the angular bindings for jquery.fileupload? If so, is the add function set in the controller of $scope.options? You may need to provide a bit more code than the above few lines. –  orange Oct 15 '13 at 11:53
    
i'm sorry :) The add function is from the example that's in the github repo, placed in my directive.js. The controller is attached to the form, so that's get called from there. In the controller function, i set 2 options, $scope.options = { url: '/api/userprofile/' + $rootScope.User.UserId + '/avatar/', type: 'POST' }; I dont know if you need any more code? –  stbeets Oct 15 '13 at 12:02
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.