84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
使用requireJS管理JS, angularJS就不需要用ng-app作为入口了吗?能详细解释下吗,不胜感激!
小弟解决了: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.