我有一个页面,其中有几个选项卡,并且我使用 Angular+Bootstrap。 我最初使用 angular.bootstrap 。 然后我有另一个 Controller ,用于在其中一个选项卡中显示不同的数据集。当我尝试再次使用 angular.bootstrap 时,出现错误,无法 Bootstrap 两次。为了简单起见,请考虑以下代码。
<div id="mainpage" ng-controller="mainPageController">
<ul>
<li id="test1"> <a href="gototest1"> GoToTest1 </li>
<li id="test2"> <a href="gototest2"> GoToTest2 </li>
</ul>
</div>
<div id="gototest1">
this is some sample. I have another html page here which will be loaded as a tab
</div
gototest1 的页面如下所示
<div ng-controller="gototestcontroller>
Here comes the another widget from another controller and
I try to use angular.boostrap here again. And I get the error because it is already bootstrapped in mainPage
</div>
在这里使用 angular.bootstrap 的最佳方法是什么?
最佳答案
Angular bootstrap 用于手动初始化 Angular 文档或元素。 https://docs.angularjs.org/guide/bootstrap
Angular 不能在一个元素上多次初始化。您不使用 ng-app
自动初始化有什么原因吗?
关于angularjs - 如何使用 angular.bootstrap 两次?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25715284/