AngularJS错误:未知提供商:aProvider< - 一个 [英] AngularJS Error: Unknown provider: aProvider <- a

查看:233
本文介绍了AngularJS错误:未知提供商:aProvider< - 一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

OK我现在正式光头,已经出streching我的头发,这个臭名昭著的问题后:本minfied AngularJS应用是行不通的,与此错误thown出来:

OK I'm officially bald now, after having been streching my hair out with this infamous problem: The minfied AngularJS app just doesn't work, with this error thown out:

错误:[$喷油器:unpr]未知提供商:aProvider< - 一个
  <一href=\"http://errors.angularjs.org/1.2.6/\">http://errors.angularjs.org/1.2.6/$injector/unpr?p0=aProvider%20%3C-%20a
      在<一个href=\"http://localhost/my-app/dist/scripts/1bde0e2e.vendor.js:4:11492\">http://localhost/my-app/dist/scripts/1bde0e2e.vendor.js:4:11492
      在<一个href=\"http://localhost/my-app/dist/scripts/1bde0e2e.vendor.js:4:26946\">http://localhost/my-app/dist/scripts/1bde0e2e.vendor.js:4:26946
      在Object.c [如GET(<一个href=\"http://localhost/my-app/dist/scripts/1bde0e2e.vendor.js:4:26250\">http://localhost/my-app/dist/scripts/1bde0e2e.vendor.js:4:26250)
      在<一个href=\"http://localhost/my-app/dist/scripts/1bde0e2e.vendor.js:4:27041\">http://localhost/my-app/dist/scripts/1bde0e2e.vendor.js:4:27041
      在C(<一个href=\"http://localhost/my-app/dist/scripts/1bde0e2e.vendor.js:4:26250\">http://localhost/my-app/dist/scripts/1bde0e2e.vendor.js:4:26250)
      在Object.d [如调用(<一个href=\"http://localhost/my-app/dist/scripts/1bde0e2e.vendor.js:4:26496\">http://localhost/my-app/dist/scripts/1bde0e2e.vendor.js:4:26496)
      在<一个href=\"http://localhost/my-app/dist/scripts/1bde0e2e.vendor.js:9:910\">http://localhost/my-app/dist/scripts/1bde0e2e.vendor.js:9:910
      在Object.f [如的forEach(<一个href=\"http://localhost/my-app/dist/scripts/1bde0e2e.vendor.js:4:11927\">http://localhost/my-app/dist/scripts/1bde0e2e.vendor.js:4:11927)
      在<一个href=\"http://localhost/my-app/dist/scripts/1bde0e2e.vendor.js:9:856\">http://localhost/my-app/dist/scripts/1bde0e2e.vendor.js:9:856
      第j(<一个href=\"http://localhost/my-app/dist/scripts/1bde0e2e.vendor.js:5:27235\">http://localhost/my-app/dist/scripts/1bde0e2e.vendor.js:5:27235)

Error: [$injector:unpr] Unknown provider: aProvider <- a http://errors.angularjs.org/1.2.6/$injector/unpr?p0=aProvider%20%3C-%20a at http://localhost/my-app/dist/scripts/1bde0e2e.vendor.js:4:11492 at http://localhost/my-app/dist/scripts/1bde0e2e.vendor.js:4:26946 at Object.c [as get] (http://localhost/my-app/dist/scripts/1bde0e2e.vendor.js:4:26250) at http://localhost/my-app/dist/scripts/1bde0e2e.vendor.js:4:27041 at c (http://localhost/my-app/dist/scripts/1bde0e2e.vendor.js:4:26250) at Object.d [as invoke] (http://localhost/my-app/dist/scripts/1bde0e2e.vendor.js:4:26496) at http://localhost/my-app/dist/scripts/1bde0e2e.vendor.js:9:910 at Object.f [as forEach] (http://localhost/my-app/dist/scripts/1bde0e2e.vendor.js:4:11927) at http://localhost/my-app/dist/scripts/1bde0e2e.vendor.js:9:856 at j (http://localhost/my-app/dist/scripts/1bde0e2e.vendor.js:5:27235)

其他人很多都有这个问题为好,但看起来可能通过声明依赖作为一个数组,而不是裸露的功能参数,像这样固定的:

Lots of other people had this problem as well, but looks like it could be fixed by declaring dependencies as an array instead of bare function parameters, like this:

angular.module('my-app').controller('LoginCtrl', [ '$scope', 'HttpService', function($scope, HttpService) { ... }]);

而不是这样的:

angular.module('my-app').controller('LoginCtrl', function($scope, HttpService) { ... });

不过,这并不在我的情况下工作。我检查了我所有的脚本(咖啡和JavaScript的产生以及),它们都使用正确的阵列式的声明。

But it doesn't work in my case. I checked all of my scripts (coffee and generated javascripts as well), they all use the proper array-style declaration.

问题并非来自额外的软件包明显。我试图将所有多余的包引用出来的&LT; - 鲍尔:JS - &GT; 块(这样它们不会被咕噜缩小的),但问题依然遗迹。这意味着,这是我的code惹的祸......不过话又说回来,我已经试过了(好像是)只提供固定,但没有成功。

The problem doesn't come from extra packages apparently. I tried moving all extra package references out of <!-- bower:js --> block (so that they are not minified by grunt), yet the problem still remains. Which means, it's my code to blame... But then again, I've tried the (seems to be) only fix available, to no avail.

任何暗示,甚至在如何正确调试呢?

Any hint, even on how to properly debug this?

在此先感谢!

推荐答案

最后,我已经找到了问题。是的,这是我错过了一个DI错误。

Finally I've found the problem. And yes, it's a DI bug which I missed.

要所有谁可以从相同的头痛是痛苦:阵列格式的声明必须在 $ routeProvider 来完成的解析选项,以及。在我的情况下(前面的CoffeeScript):

To all who may be suffering from the same headache: array-format declaration must be done in $routeProvider's resolve options as well. In my case (CoffeeScript ahead):

app.config (['$routeProvider', ($routeProvider) ->
  $routeProvider
    .when '/',
      templateUrl: 'views/main.html'
      controller: 'MainCtrl'
      resolve: 
        groups: ['GroupService', (GroupService) ->  # I MISSED THIS
          return GroupService.getAll()
        ]
        entries: ['EntryService', (EntryService) ->  # AND THIS
          return EntryService.getAll()
        ]
    # ...
])

希望这有助于!

这篇关于AngularJS错误:未知提供商:aProvider&LT; - 一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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