之前已经提出过这个问题,我看到大多数答案都建议查看执行此操作的角种子:
// include angular loader, which allows the files to load in any order
/*
AngularJS v1.0.0rc1
(c) 2010-2012 AngularJS http://angularjs.org
License: MIT
*/
'use strict';(function ..............................................
$script([
'lib/angular/angular.js',
'js/app.js',
'js/services.js'
], function() {
// when all is done, execute bootstrap angular application
angular.bootstrap(document, ['myApp']);
});
但是我还是不明白装载机有什么优势。有人可以向我解释一下上面和下面的代码有什么区别:
<script src='lib/angular/angular.js'></script>
<script src='js/app.js'></script>
<script src='js/services.js'></script>
<script type="text/javascript">
angular.element(document).ready(function () {
angular.bootstrap(document, ['mainApp']);
});