[英]How to use angular.bootstrap twice?
我有一個頁面,其中有幾個選項卡,我使用angular + bootstrap。 我最初使用angular.bootstrap。 然后我有另一個控制器,用於在其中一個選項卡中顯示不同的數據集。 當我再次嘗試使用angular.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
自動初始化?
聽起來您可以使用模塊ngRoute
並應用attirbute ng-view
而不是嘗試兩次引導程序。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.