If you use requireJS to manage JS, doesn’t angularJS need to use ng-app as the entry point?
Can you explain it in detail? Thank you very much!
My brother solved it: http://www.open-open.com/lib/view/open14...
曾经蜡笔没有小新2017-05-15 17:02:05
Since require.js is loaded asynchronously instead of blocking, when using require.js to load angular, if ng-app is defined in html, such a situation can easily occur.
So we cannot directly use ng-app to define angular modules
The solution is as follows:
define([ 'angular' , 'angular-ui-router' ] , function( angular ){
window.name = 'NG_DEFER_BOOTSTRAP';
var isloaded = false;
var timer = setInterval(function(){
angular.element(document).ready(function(){
angular.bootstrap(document,["My_app"]);
isloaded = true;
});
if(isloaded === true){
clearInterval(timer);
}
},300);
return angular.module('My_app',['ui.router']);
});
漂亮男人2017-05-15 17:02:05
I feel that gulp is better, requirejs is a little troublesome, and I have to write extra code for each js file, which I don’t like.