vendredi 6 février 2015

Angular dependencies and provider not available error


I am loading a file upload script I found on Github



<script type="text/javascript" src="{% static 'bower_components/angular-file-upload/angular-file-upload.min.js' %}"></script>


and have a data import module :



(function () {
'use strict';

angular
.module('TestSite.import', [
'TestSite.import.controllers'
]);

angular
.module('TestSite.import.controllers', ['angularFileUpload']);
})();


as well as a controller



(function () {
'use strict';

angular
.module('TestSite.import.controllers' , ['angularFileUpload'])
.controller('UploadController', UploadController);

UploadController.$inject = ['$scope','angularFileUpload'];

/**
* @namespace UploadController
*/
function UploadController($scope, FileUploader) {
$scope.uploader = new FileUploader();

};

})();


And I am getting an error



Error: [$injector:unpr] Unknown provider: angularFileUploadProvider <- angularFileUpload


I am confused about the module declaration and DI. Why do I need to declare the module TestSite.import.controllers twice? I am injecting the right dependencies (angularFileUpload) and still getting that error, also what is a provider and why cant angular find it?





Aucun commentaire:

Enregistrer un commentaire