我想第一次使用AngularJS和RequireJS一起使用this guide作爲基礎。據我可以有很多的調試我加載正確的順序我的所有模塊後告訴我們,但在應用程序運行時角度拋出Error /異常以下消息:AngularJS和RequireJS:沒有模塊:myApp
參數「FN」是不是一個函數,得到了串從對myApp
我已經看到由於語法錯誤,在此之前的消息,所以即使我已經看了多次低谷的代碼,我不排除會簡單的可能性語法錯誤。如果它只是語法錯誤這樣簡單的東西,那麼還沒有製作小提琴,但是如果需要的話,我當然會這樣做。
更新:在<html>
標籤我也得到一個額外的錯誤設置NG-應用= 「對myApp」 當我剛剛注意到,
無模塊:對myApp
更新II:好的,事實證明它確實是在下面沒有包含的唯一文件中的語法錯誤。我雖然還是留下的問題從一更新
RequireJS引導
'use strict';
define([
'require',
'angular',
'app/myApp/app',
'app/myApp/routes'
], function(require, ng) {
require(['domReady'], function(domReady) {
ng.bootstrap(domReady, ['myApp']);
});
});
app.js
'use strict';
define([
'angular',
'./controllers/index'
], function(ng) {
return ng.module('myApp', [
'myApp.controllers'
]);
}
);
控制器/指數
'use strict';
define([
'./front-page-ctrl'
], function() {
});
個
控制器/模塊
'use strict';
define(['angular'], function (ng) {
return ng.module('myApp.controllers', []);
});
控制器/頭版-CTRL
'use strict';
define(['./module'], function(controllers) {
controllers.
controller('FrontPageCtrl', ['$scope',
function($scope) {
console.log('I\'m alive!');
}
]);
});
您發佈的問題一旦發佈就不應該改變,因爲現有的答案沒有上下文。關於你的新的「無模塊」問題,這是因爲你不應該使用'ng-app'。 'ng.bootstrap'與'ng-app'具有完全相同的用途。有關更多信息,請參閱http://stackoverflow.com/a/17498509/1095616。 – Stewie
對不起。在我更新之後,我意識到引導部分。當你指出我在這裏正確的方向時,你的答案會被接受。 –