真正結束這一個轉彎瘋狂:AngularAMD + RequireJS:無法實例化模塊ngStorage
我試圖AngularJS和RequireJS結合起來。幾次失敗後,我轉向AngularAMD。我遵循的基本過程,但我不斷收到這個討厭的錯誤:
Failed to instantiate module ngStorage due to: Module 'ngStorage' is not available! You either misspelled the module name or forgot to load it...
ngStorage是一個簡單的第三方角模塊。
這裏是我的main.js:
require.config({
paths: {
angular: 'js/angular.min',
angularAMD: 'js/angularAMD.min',
ngload: 'js/ngload.min',
ngStorage: 'js/ngStorage.min'
},
shim: {
angularAMD: ['angular'],
ngload: ['angularAMD'],
ngStorage: ['angular'] // Also tried with ['angularAMD'], and without this line at all
},
deps: ['js/app']
});
而且我app.js:
define(['angularAMD','ngStorage'], function(angularAMD) {
var app = angular.module('tyleApp', ['ngStorage']);
return angularAMD.bootstrap(app); // Fails here...
});
我刪除一切從應用程序,它只是失敗這裏...我究竟做錯了什麼?
注:我也嘗試過用:
define(['angularAMD','ngload!ngStorage'], function(angularAMD) {
但後來我得到:
angularAMD not initialized. Need to call angularAMD.bootstrap(app) first.
請確保從瀏覽器的控制檯,ngStorage.min.js實際上加載.. – nhaa123
@ nhaa123:好點:它確實沒有加載。但爲什麼不呢? –
你確定有 /js/ngStorage.min.js可用嗎? :) –
nhaa123