如何动态加载模块脚本。
我有两个JS文件:
module1.js
(function() {
var mod = angular.module('module1', []);
....
})();这是第二个:
module2.js
(function() {
var mod = angular.module('module2', ['module1']);
....
})();当module2.js需要时,我想动态加载module1.js。
有什么方法可以用源URL“映射”模块名吗?就像这样:
angular.registerModuleSource('module1', 'http://myhost.com/app/module1.js')
angular.registerModuleSource('module2', 'http://myhost.com/app/module2.js')发布于 2014-11-06 11:13:23
为此,您可以使用require.js。
发布于 2014-11-06 11:10:35
为此目的使用require.js。这样您就可以在运行时加载模块。
https://stackoverflow.com/questions/26777815
复制相似问题