angularjs角文件上传未知提供商:$ uploadProvider错误 [英] angularjs angular-file-upload Unknown provider: $uploadProvider error

查看:928
本文介绍了angularjs角文件上传未知提供商:$ uploadProvider错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是不是这个问题重复

我已经包括针对所有必需的文件:

<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>

我的模块和控制器:

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.

错误:[$喷油器:unpr]未知提供商:$ uploadProvider

请帮助我。

推荐答案

看来,你没有正确关闭控制器声明。

It appears that you didn't close the controller declaration correctly.

具体而言,您有:}); 的时候,你应该有}]); 来代替。注意失踪]

Specifically, you have: }); when you should have }]); instead. Note the missing ].

在情况下,你应该有:

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 是简洁,而且pretty succint:

because we need to follow the form of declaring a controller. The controller API is terse, but pretty succint:

$controller(constructor, locals);

从而扩大您的情况:

Which expanded to your case:

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

我额外的间距增加调出丢失的] ,并展示如何我们在声明中封山育林元素。

I added in extra spacing to call out the missing ] and to show how we're closing off elements within the declaration.

这篇关于angularjs角文件上传未知提供商:$ uploadProvider错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆