Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在index.html中动态加载AngularJS文件?_Angularjs - Fatal编程技术网

如何在index.html中动态加载AngularJS文件?

如何在index.html中动态加载AngularJS文件?,angularjs,Angularjs,每个应用程序都有不同的模块,因此它们需要在index.html中加载不同的编译js文件,如下所示 只是发现它不起作用。那么有没有一个好的方法呢?或者需要任何回调来手动启动AngularJS应用程序?谢谢 <script> var appId = unescape(window.location.href).split('#/')[1].split('/')[0]; loadComponent('../.tmp/client/scripts/' + appId + '.

每个应用程序都有不同的模块,因此它们需要在index.html中加载不同的编译js文件,如下所示

只是发现它不起作用。那么有没有一个好的方法呢?或者需要任何回调来手动启动AngularJS应用程序?谢谢

<script>
    var appId = unescape(window.location.href).split('#/')[1].split('/')[0];
    loadComponent('../.tmp/client/scripts/' + appId + '.js');
</script>

您可以使用RequirejS进行动态加载。您可以将Angular和RequireJS结合使用,以获得性能更好的应用程序

谢谢,这是使用requires.js的好方法。但我只想加载一个js文件,而不是延迟加载每个AngularJS模块。