简体   繁体   English

uib-tabset无法从外部模板加载

[英]uib-tabset not loading from external template

version:ui-bootstrap-tpls-2.5.0.min.js 版本:ui-bootstrap-tpls-2.5.0.min.js

I am facing issue in loading tabs defined in external html file. 我在加载外部html文件中定义的标签时遇到问题。 In index.html file I have referred the tab which is defined in the external template. 在index.html文件中,我引用了在外部模板中定义的选项卡。

<div class="col-lg-12 col-xs-12 col-sm-12 col-md-12 no-padding" template="Scripts/tpl/optionTab.tpl.html" templateUrl="Scripts/tpl/optionTab.tpl.html" ></div>

I have following example code defined in file Scripts/tpl/optionTab.tpl.html 我在文件Scripts / tpl / optionTab.tpl.html中定义了以下示例代码

<uib-tabset active="active">
<uib-tab index="0" heading="Static title">Static content</uib-tab>
<uib-tab index="$index + 1" ng-repeat="tab in tabs" heading="{{tab.title}}" disable="tab.disabled">
  {{tab.content}}
</uib-tab>
<uib-tab index="3" select="alertMe()">
  <uib-tab-heading>
    <i class="glyphicon glyphicon-bell"></i> Alert!
  </uib-tab-heading>
  I've got an HTML heading, and a select callback. Pretty cool!
</uib-tab>

The above code works fine if i add it directly into the index.html file ie without referring the same from external template. 如果我直接将其直接添加到index.html文件中,而无需从外部模板引用相同文件,则上述代码可以正常工作。 Can anyone please guide as what is the issue here ? 有人可以指导,因为这里有什么问题? There is no error in console. 控制台中没有错误。 i have tried template, templatUrl, ng-include but nothing worked. 我已经尝试过模板,templatUrl,ng-include,但没有任何效果。

You had a typo. 你有错字 Use template-url attribute instead of templateUrl . 使用template-url属性代替templateUrl

template-url="Scripts/tpl/optionTab.tpl.html" 

Plunker 柱塞

I am posting answer for my own question as it might help someone new to angular like me. 我正在为自己的问题发布答案,因为这可能会帮助像我这样的新手。

I can't believe that it was a very simple solution and no expert could helped to point in right direction. 我不敢相信这是一个非常简单的解决方案,没有专家可以帮助指出正确的方向。 What all I wanted was to include the uib-tabset defined in external html file into the index.html. 我想要的只是将在外部html文件中定义的uib-tabset包含到index.html中。 I tried the options of uib-tabset such as template-url(seem like it is bug as it is not picking the external file and throwing error such as multiple root elements etc). 我尝试了uib-tabset的选项,例如template-url(似乎是个错误,因为它没有选择外部文件并抛出诸如多个根元素之类的错误)。 I tried ng-include but nothing seem to work. 我尝试了ng-include,但似乎没有任何效果。 Shared plunker on request etc ultimatley I found that following is what all I needed in index.html to solve it. 我在请求中共享了pluker,最后发现,以下是我需要在index.html中解决的所有内容。

 <div ng-include src="'Scripts/tpl/optionTab.tpl.html'"></div>

I was missing the single quote before the path and angular was not importing the partial html containing uib-tabset as it was trying to parse the path as variable. 我在路径之前缺少单引号,而angular则没有导入包含uib-tabset的部分html,因为它试图将路径解析为变量。 With single quote it treated as string and it worked. 用单引号将其视为字符串并且可以正常工作。 Thanks to post below which helped. 感谢下面的帖子,它有所帮助。

What is the correct syntax of ng-include? ng-include的正确语法是什么?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM