angularjs – 使用ng-file-upload接收“未知提供者:UploadProvider”错误

我正在尝试使用ng-file-upload指令( https://github.com/danialfarid/ng-file-upload)将文件上传功能添加到我的项目中,但不断收到此错误:

Error: [$injector:unpr] http://errors.angularjs.org/1.4.6/$injector/unpr?p0=UploadProvider%20%3C-%20Upload%20%3C-%20ExperimentController
at Error (native)
at http://localhost:8000/static/editor/js/angular.min.js:6:416
at http://localhost:8000/static/editor/js/angular.min.js:40:409
at Object.d [as get] (http://localhost:8000/static/editor/js/angular.min.js:38:394)
at http://localhost:8000/static/editor/js/angular.min.js:40:483
at d (http://localhost:8000/static/editor/js/angular.min.js:38:394)
at e (http://localhost:8000/static/editor/js/angular.min.js:39:161)
at Object.instantiate (http://localhost:8000/static/editor/js/angular.min.js:39:310)
at http://localhost:8000/static/editor/js/angular.min.js:80:313
at A.link (http://localhost:8000/static/editor/js/angular-route.min.js:7:268) <div ng-view="" ng-show="main.results==null" class="ng-scope">

我在index.html中包含了正确的文件:

<script src="/static/editor/js/angular.min.js"></script>
<script src="/static/editor/js/ng-file-upload-shim.js"></script>
<script src="/static/editor/js/ng-file-upload.js"></script>

我宣布它是我的模块:

(function() {
    angular
        .module('myApp',[
            'ngRoute','ngAnimate','ngCookies','ngFileUpload'
    ]);
})();

但当我尝试将其注入我的控制器时,它会抛出上述错误:

(function() {
    angular
        .module('myApp')
        .controller('myController',myController);

    myController.$inject = ['$routeParams','$compile','$scope','$interval','Upload'];


function myController($routeParams,$compile,$scope,$interval,Upload) {
....

我正在使用Angular 1.4.6和ng-file-upload 9.0.14.我手动下载了文件,并在项目目录中包含了指示的.js文件.是否有一些额外的依赖关系,包括通过bower或npm,我缺少?

任何帮助将不胜感激!

更新:使用AngularJS 1.4.6(https://angular-file-upload.appspot.com/#/1.4.6)查看ng-file-upload指令的实时演示页面也会导致大量错误,因此这可能与1.4.6和最新版本的ng-file-upload不兼容.

解决方法

您正在尝试注入名为“上传”的未知服务,如果您的意思是ng-file-upload的上传服务,则需要注入“ngFileUpload”而不是“Upload”.

myController.$inject = ['$routeParams','ngFileUpload'];

function myController($routeParams,ngFileUpload) {
....

相关文章

ANGULAR.JS:NG-SELECTANDNG-OPTIONSPS:其实看英文文档比看中...
AngularJS中使用Chart.js制折线图与饼图实例  Chart.js 是...
IE浏览器兼容性后续前言 继续尝试解决IE浏览器兼容性问题,...
Angular实现下拉菜单多选写这篇文章时,引用文章地址如下:h...
在AngularJS应用中集成科大讯飞语音输入功能前言 根据项目...
Angular数据更新不及时问题探讨前言 在修复控制角标正确变...