1. <legend id='1WRYx'><style id='1WRYx'><dir id='1WRYx'><q id='1WRYx'></q></dir></style></legend>
  2. <small id='1WRYx'></small><noframes id='1WRYx'>

  3. <i id='1WRYx'><tr id='1WRYx'><dt id='1WRYx'><q id='1WRYx'><span id='1WRYx'><b id='1WRYx'><form id='1WRYx'><ins id='1WRYx'></ins><ul id='1WRYx'></ul><sub id='1WRYx'></sub></form><legend id='1WRYx'></legend><bdo id='1WRYx'><pre id='1WRYx'><center id='1WRYx'></center></pre></bdo></b><th id='1WRYx'></th></span></q></dt></tr></i><div id='1WRYx'><tfoot id='1WRYx'></tfoot><dl id='1WRYx'><fieldset id='1WRYx'></fieldset></dl></div>
        <bdo id='1WRYx'></bdo><ul id='1WRYx'></ul>

      <tfoot id='1WRYx'></tfoot>
    1. AngularJS 错误:未知提供者:aProvider &lt;- a

      AngularJS Error: Unknown provider: aProvider lt;- a(AngularJS 错误:未知提供者:aProvider lt;- a)

          <tbody id='yLWnl'></tbody>

              <i id='yLWnl'><tr id='yLWnl'><dt id='yLWnl'><q id='yLWnl'><span id='yLWnl'><b id='yLWnl'><form id='yLWnl'><ins id='yLWnl'></ins><ul id='yLWnl'></ul><sub id='yLWnl'></sub></form><legend id='yLWnl'></legend><bdo id='yLWnl'><pre id='yLWnl'><center id='yLWnl'></center></pre></bdo></b><th id='yLWnl'></th></span></q></dt></tr></i><div id='yLWnl'><tfoot id='yLWnl'></tfoot><dl id='yLWnl'><fieldset id='yLWnl'></fieldset></dl></div>
              <tfoot id='yLWnl'></tfoot>
              <legend id='yLWnl'><style id='yLWnl'><dir id='yLWnl'><q id='yLWnl'></q></dir></style></legend>

              <small id='yLWnl'></small><noframes id='yLWnl'>

              • <bdo id='yLWnl'></bdo><ul id='yLWnl'></ul>
              • 本文介绍了AngularJS 错误:未知提供者:aProvider &lt;- a的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                好吧,在解决了这个臭名昭著的问题之后,我现在正式秃顶了:缩小的 AngularJS 应用程序无法正常工作,解决了这个错误:

                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:

                错误:[$injector:unpr] 未知提供者:aProvider <- ahttp://errors.angularjs.org/1.2.6/$injector/unpr?p0=a提供者%20%3C-%20a在 http://localhost/my-app/dist/scripts/1bde0e2e.vendor.js:4:11492在 http://localhost/my-app/dist/scripts/1bde0e2e.vendor.js:4:26946在 Object.c [as get] (http://localhost/我的应用程序/dist/scripts/1bde0e2e.vendor.js:4:26250)在 http://localhost/my-app/dist/scripts/1bde0e2e.vendor.js:4:27041在 c (http://localhost/my-app/dist/脚本/1bde0e2e.vendor.js:4:26250)在 Object.d [作为调用] (http://localhost/我的应用程序/dist/scripts/1bde0e2e.vendor.js:4:26496)在 http://localhost/my-app/dist/scripts/1bde0e2e.vendor.js:9:910在 Object.f [as forEach] (http://localhost/我的应用程序/dist/scripts/1bde0e2e.vendor.js:4:11927)在 http://localhost/my-app/dist/scripts/1bde0e2e.vendor.js:9:856在 j (http://localhost/my-app/dist/脚本/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.

                问题显然不是来自额外的包.我尝试将所有额外的包引用移出 <!-- bower:js --> 块(这样它们就不会被 grunt 缩小),但问题仍然存在.这意味着,这是我的代码的错……但话又说回来,我尝试了(似乎是)唯一可用的修复程序,但无济于事.

                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.

                对于所有可能遭受同样头痛的人:数组格式声明也必须在 $routeProviderresolve 选项中完成.在我的情况下(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;- a的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Rails/Javascript: How to inject rails variables into (very) simple javascript(Rails/Javascript:如何将 rails 变量注入(非常)简单的 javascript)
                quot;Each child in an array should have a unique key propquot; only on first time render of page(“数组中的每个孩子都应该有一个唯一的 key prop仅在第一次呈现页面时)
                Rails 3.1 ajax:success handling(Rails 3.1 ajax:成功处理)
                CoffeeScript always returns in anonymous function(CoffeeScript 总是以匿名函数返回)
                Ordinals in words javascript(javascript中的序数)
                getFullYear returns year before on first day of year(getFullYear 在一年的第一天返回前一年)

                        <legend id='bsarH'><style id='bsarH'><dir id='bsarH'><q id='bsarH'></q></dir></style></legend>
                        <tfoot id='bsarH'></tfoot>
                          <tbody id='bsarH'></tbody>

                        <small id='bsarH'></small><noframes id='bsarH'>

                        • <bdo id='bsarH'></bdo><ul id='bsarH'></ul>
                          <i id='bsarH'><tr id='bsarH'><dt id='bsarH'><q id='bsarH'><span id='bsarH'><b id='bsarH'><form id='bsarH'><ins id='bsarH'></ins><ul id='bsarH'></ul><sub id='bsarH'></sub></form><legend id='bsarH'></legend><bdo id='bsarH'><pre id='bsarH'><center id='bsarH'></center></pre></bdo></b><th id='bsarH'></th></span></q></dt></tr></i><div id='bsarH'><tfoot id='bsarH'></tfoot><dl id='bsarH'><fieldset id='bsarH'></fieldset></dl></div>