Angularjs angular -file-upload Unknown provider: $ uploadProvider error

This is not a duplicate. This question

I have included all the necessary files:

<script src="~/Scripts/angular-file-upload-master/examples/console-sham.min.js"></script>
<script src="~/Content/js/angular.js"></script>
<script src="~/Scripts/angular-file-upload-master/angular-file-upload.js"></script>

My module and controller:

var controllers = angular.module('controllers', ['ngGrid', 'ngDialog', 'angularFileUpload']);

controllers.controller('CustomProductsCtrl', 
 ['$scope', '$window', 'ngDialog', 'CommonService', 
   'CustomProductsServices', '$upload', 
 function ($scope, $window, ngDialog, CommonService, 
   CustomProductsServices, $upload){

});

But still I get this error.

Error: [$ injector: unpr] Unknown provider: $ uploadProvider

Please help me.

+4
source share
3 answers

It looks like you did not close the ad controllercorrectly.

In particular, you have: });when you should have }]);. Pay attention to the missing ].


In context, you should have:

var controllers = angular.module('controllers', ['ngGrid', 'ngDialog', 'angularFileUpload']);

controllers.controller('CustomProductsCtrl', 
 ['$scope', '$window', 'ngDialog', 'CommonService', 
   'CustomProductsServices', '$upload', 
 function ($scope, $window, ngDialog, CommonService, 
   CustomProductsServices, $upload){

}]);  // Note: missing ']' added in here

. API- API , :

$controller(constructor, locals);

:

module_name.controller( 'your_Ctrl', 
    [locals, function(){ 
        } 
    ] 
);

, ] , .

+2

, , $upload , FileUploader:

controllers.controller('CustomProductsCtrl',
  [..., '$upload', function (..., 'FileUploader') {

, , . FYI, , angular -file-upload.js:

.factory('FileUploader', ['fileUploaderOptions', '$rootScope', '$http', '$window', '$compile',
+6

, ng-file-upload:

https://github.com/danialfarid/ng-file-upload/issues/45

- , :

angular.module('starter.controllers', ['ngFileUpload'])
.controller('HomeCtrl', function($scope, ... Upload) {
   ...
   file.upload = Upload.upload({...}); //Upload instead of $upload
   ...
})
0
source

All Articles