javascript - TypeError: Upload.upload is not a function -


i have function, , throw exception:

$scope.uploadavatar = function(avatar, user) {    upload.upload({         url: 'api/v1/user' + user.id + '/',         avatar: avatar,         method: 'put'     }) }; 

typeerror: upload.upload not function

my scripts includes:

    <script src="/static/js/main.js"></script>     <script src="/static/js/bootstrap.min.js"></script>     <script src="/static/js/posts_controller.js"></script>     <script src="/static/js/jquery.equalheights.min.js"></script>     <script src="/static/js/video.js/video.js"></script>     <script src="/static/js/swiper.jquery.min.js"></script>     <script src="/static/ng-file-upload/fileapi.js"></script>     <script src="/static/ng-file-upload/ng-file-upload.js"></script>     <script src="/static/ng-file-upload/ng-file-upload-all.js"></script>     <script src="/static/ng-file-upload/ng-file-upload-shim.js"></script>     <script src="/static/ng-file-upload/ng-file-upload.js"></script> 

so did inject 'upload' in controller , 'ngfileupload' in module controller:

myapp.controller('showslistcontroller', ['$scope', '$http', '$routeparams', '$location', '$route', 'upload', function ($scope, $http, $routeparams, $route, upload) {      $http.get('/api/v1/shows/').success(function (data) {         $scope.shows = data;     });       $http.get('/check_login/').success(function (data) {         $scope.mediaurl = data.mediaurl;         $scope.user = data;      });        $http.get('/api/v1/actors/').success(function (data) {         $scope.actors = data;     });      $http.get('/api/v1/users/').success(function (data) {         $scope.users = data;     });       $scope.uploadavatar = function (avatar, user) {          upload.upload({             url: 'api/v1/users' + user.id + '/',             avatar: avatar,             method: 'put'         })     };  }]); 

add controller these function

in controller declaration, injected $location after $routeparams forgot pass in function.

since using inline array annotation, need keep annotation array in sync parameters in function declaration itself.

myapp.controller('showslistcontroller', ['$scope', '$http', '$routeparams', '$location', '$route', 'upload', function ($scope, $http, $routeparams, $location, $route, upload) {  // current code } 

see docs more info.


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -