2013-02-15 110 views
11

我使用的角度-UI的標籤:角UI選項卡使用該控制器選項卡內容加載模板

$scope.panes = [ 
    { title:"Home",  content:"home" , active: true}, 
    { title:"Settings", content:"settings"}, 
    { title:"View",  content:"view"} 
]; 

,這在HTML文件中:

<tabs> 
    <pane 
     active="pane.active" 
     heading="{{pane.title}}" 
     ng-repeat="pane in panes" 
    > 
     {{pane.content}} 
    </pane> 
    </tabs> 

但我想要將內容設置爲模板,我該如何做到這一點,我嘗試在此plunker中設置ng-include代碼,但沒有奏效。
在此先感謝。

更新:

如果你發現這個解決方案,找你不使用的角度,引導v0.12您需要將代碼更新到the new syntax of v0.13這樣的:

<tabset> 
    <tab 
     active="pane.active" 
     heading="{{pane.title}}" 
     ng-repeat="pane in panes" 
    > 
     <div ng-include="pane.content"></div> 
    </tab> 
    </tabset> 

我已經更新了plunker具有angular-bootstrap v0.13的語法。

回答

25

只需添加NG-包括的窗格

<tabs> 
    <pane active="pane.active" 
      heading="{{pane.title}}" 
      ng-repeat="pane in panes"> 
     <div ng-include="pane.content"></div> 
    </pane> 
</tabs> 
的孩子

這部作品的原因是,當您使用範圍變量窗格中尚不可用的在NG-包括與創建窗格變量的ng-repeat相同。

這是因爲優先級值的NG-包括是0(默認值),而NG-重複的優先級爲1000等執行的順序是:

  1. NG-包括
  2. NG-重複

請參閱工作的directive docs

+0

謝謝,但你可以解釋爲什麼它的工作這種方式並不怎麼我第一次寫它,或者只是指出我在哪裏可以找到它。 – 2013-02-15 15:18:08

+1

查看我的更新回答 – 2013-02-15 15:29:45

+0

這很清楚,謝謝。 – 2013-02-15 15:36:24

相關問題