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...
学习是最好的投资!
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']); });
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.
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:
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.