问题描述
我最近玩过Angular,但我不知道从哪里开始将多个外部html应用程序链接到一个html文档中。
如果还不清楚,请告诉我。
谢谢 :)
1楼
GPicazo
1
2015-07-30 16:03:31
假设您已经创建了角度应用程序,并且这2个(假设2个)不同应用程序的主要模块是myApp1和myApp2 ,则以下内容应该可以工作:
<!-- index.html (or whatever the page is called) -->
<html>
<body>
<div ng-app="myApp1">...</div>
<div ng-app="myApp2" id="app2>...</div>
<script ...> <!-- script(s) that include the sources of the apps -->
<script>
angular.bootstrap(document.getElementById("app2"),['myApp2']);
</script>
</body>
</html>
更新:第二个应用程序必须在代码中引导。
这是一个工作示例: :
2楼
Mesopotamia
0
2015-07-30 16:58:24
一种选择,也许最简单的选择是使用两个iframe。
您可以让每个应用程序加载其所有外部依赖项,而不必担心冲突。