2013-02-15 109 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

相关问题