admin管理员组文章数量:1391964
I'm working on some Bootstrap-UI tabs, but I can't find an instance online that uses templateURL
without manipulating the URL of the page. Here's what I'd like to do:
HTML
<uib-tabset active="active">
<uib-tab ng-repeat="tab in model.tabs" index="$index" heading="{{tab.title}}">
{{tab.content}}
</uib-tab>
</uib-tabset>
JS
model.jo = {...} // a gigantic JSON object - needs to be available in the templates.
model.tabs = [
{
title: "Visualized",
content: url('vis.html')
},
{
title: "Pure JSON",
content: url('json.html')
}
]
Most of the stuff I found online uses $routeProvider
& $locationProvider
to doctor up the URL in order to show different tabs, like this one: /. I don't want to do that.
Is there any way to just define the templateUrl
like you'd do for a ponent?
Also, I need my JSON Object, model.jo
, in the html pages.
I'm working on some Bootstrap-UI tabs, but I can't find an instance online that uses templateURL
without manipulating the URL of the page. Here's what I'd like to do:
HTML
<uib-tabset active="active">
<uib-tab ng-repeat="tab in model.tabs" index="$index" heading="{{tab.title}}">
{{tab.content}}
</uib-tab>
</uib-tabset>
JS
model.jo = {...} // a gigantic JSON object - needs to be available in the templates.
model.tabs = [
{
title: "Visualized",
content: url('vis.html')
},
{
title: "Pure JSON",
content: url('json.html')
}
]
Most of the stuff I found online uses $routeProvider
& $locationProvider
to doctor up the URL in order to show different tabs, like this one: http://embed.plnkr.co/TMN3KNlS4Dv90SvbTQKJ/. I don't want to do that.
Is there any way to just define the templateUrl
like you'd do for a ponent?
Also, I need my JSON Object, model.jo
, in the html pages.
1 Answer
Reset to default 8You could use ng-include
to render template by using its template URL. The only thing you need to change in your tabs
object is, have templateUrl
instead of content
property.
<uib-tabset active="active">
<uib-tab ng-repeat="tab in model.tabs" index="$index" heading="{{tab.title}}">
<div ng-include="tab.templateUrl"></div>
</uib-tab>
</uib-tabset>
Change tabs
object to
model.tabs = [
{
title: "Visualized",
templateUrl: 'vis.html'
},
{
title: "Pure JSON",
templateUrl: 'json.html'
}
]
Also, ng-include
uses the same controller as the source, so you will be able to access the model, specifically model.jo
, in both of those pages. Source: Pass parameter to Angular ng-include
版权声明:本文标题:javascript - Bootstrap-UI - How to use TemplateUrl for a tab view without manipulating the URL? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744735866a2622322.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论