I'm using the tabs in angular-ui using this controller:
我使用的是angular-ui中的选项卡使用这个控制器:
$scope.panes = [
{ title:"Home", content:"home" , active: true},
{ title:"Settings", content:"settings"},
{ title:"View", content:"view"}
];
and this in the html file:
在html文件中:
<tabs>
<pane
active="pane.active"
heading="{{pane.title}}"
ng-repeat="pane in panes"
>
{{pane.content}}
</pane>
</tabs>
but i want to set the content as a template how can I do that, I tried setting the ng-include code in this plunker, but didn't work.
Thanks in advance.
但是我想将内容设置为模板我怎么做呢,我尝试在这个插件中设置ng-include代码,但是没有成功。提前谢谢。
update:
if you find this solution and you'r not using angular-bootstrap v0.12 you need to update the code to the new syntax of v0.13 like this:
如果您找到了这个解决方案,并且没有使用angular-bootstrap v0.12,那么需要将代码更新为v0.13的新语法,如下所示:
<tabset>
<tab
active="pane.active"
heading="{{pane.title}}"
ng-repeat="pane in panes"
>
<div ng-include="pane.content"></div>
</tab>
</tabset>
I already updated the plunker to have the syntax of the angular-bootstrap v0.13.
我已经更新了柱塞,使其具有angular-bootstrap v0.13的语法。
1 个解决方案
#1
25
Just add the ng-include as a child of the pane
只需将ng-include添加为窗格的子元素
<tabs>
<pane active="pane.active"
heading="{{pane.title}}"
ng-repeat="pane in panes">
<div ng-include="pane.content"></div>
</pane>
</tabs>
The reason this works is that the scope variable pane is not yet available when you use the ng-include in the same element as the ng-repeat that creates the pane variable.
这样做的原因是,当您使用与创建窗格变量的ng-repeat相同的元素时,范围变量窗格还不可用。
This is because the priority value of the ng-include is 0(the default) while the priority of the ng-repeat is 1000 and so the order of execution is:
这是因为ng-include的优先级值为0(默认值),而ng-repeat的优先级为1000,执行顺序为:
- ng-include
- ng-include
- ng-repeat
- ng-repeat
See the directive docs
看到指令文档
#1
25
Just add the ng-include as a child of the pane
只需将ng-include添加为窗格的子元素
<tabs>
<pane active="pane.active"
heading="{{pane.title}}"
ng-repeat="pane in panes">
<div ng-include="pane.content"></div>
</pane>
</tabs>
The reason this works is that the scope variable pane is not yet available when you use the ng-include in the same element as the ng-repeat that creates the pane variable.
这样做的原因是,当您使用与创建窗格变量的ng-repeat相同的元素时,范围变量窗格还不可用。
This is because the priority value of the ng-include is 0(the default) while the priority of the ng-repeat is 1000 and so the order of execution is:
这是因为ng-include的优先级值为0(默认值),而ng-repeat的优先级为1000,执行顺序为:
- ng-include
- ng-include
- ng-repeat
- ng-repeat
See the directive docs
看到指令文档