好吧我現在已經正式禿頂了,因爲這個臭名昭着的問題讓我的頭髮變得模糊:最後的AngularJS應用程序不起作用,帶着這個錯誤:AngularJS錯誤:未知的提供者:aProvider < - a
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)
很多其他人也有這個問題爲好,但看起來像它可以通過聲明的依賴性被固定爲一個數組,而不是裸函數的參數,就像這樣:
angular.module('my-app').controller('LoginCtrl', [ '$scope', 'HttpService', function($scope, HttpService) { ... }]);
,而不是這樣的:
angular.module('my-app').controller('LoginCtrl', function($scope, HttpService) { ... });
但它不適用於我的情況。我檢查了我的所有腳本(咖啡和生成的javascripts),它們都使用適當的數組式樣聲明。
這個問題顯然不是來自額外的軟件包。我嘗試將所有額外的軟件包引用移出<!-- bower:js -->
塊(這樣它們不會被grunt壓縮),但問題仍然存在。這意味着,這是我的代碼責怪...但是,再次,我試過(似乎是)只有修復可用,無濟於事。
任何提示,即使在如何正確調試此?
提前致謝!
您可以禁用縮小,看看哪個供應商拋出此錯誤。 – Chandermani
那麼,如果我禁用縮小,只是與'grunt serve'一起去,沒有錯誤拋出 - 該應用程序只是完美的作品。 –
一個接一個地禁用你的模塊,以便檢測出你的代碼中存在錯誤的部分。某處有你的DI錯誤。 –