[英]Activate first one from dynamically loaded tabs in UI Bootstrap
I am using UI Boostrap ( http://angular-ui.github.com/bootstrap ) with AngularJS and Jade. 我正在将UI Boostrap( http://angular-ui.github.com/bootstrap )与AngularJS和Jade一起使用。 I am not able to get that the first tab from a set dynamically generated could be selected when the section is loaded. 我无法获得该部分加载时从动态生成的集合中选择的第一个选项卡。 This is my code: 这是我的代码:
div#attachments-section
tabs
pane(ng-repeat='attach in attachments', heading='{{attach.filename}}', active='attach.active')
div.content
object(width='100%', height='100%', data='{{"http://localhost/files/" + attach.content}}')
It means, when the section (#attachments-section) is loaded, none tab is selected. 这意味着,在加载部分(#attachments-section)时,未选择任何选项卡。 I attempted assigning a true value for the attribute active in the first element of the JSON collection (attachments) but it doesn't work. 我尝试为JSON集合(附件)的第一个元素中的active属性分配一个true值,但是它不起作用。
Check: I have updated my code (with an object tag) because I need to show every attachment using PDF's browser viewer. 检查:我已经更新了代码(带有对象标记),因为我需要使用PDF的浏览器查看器显示每个附件。
Update I followed @blesh suggestion and I could realize that it works well in Firefox but not in Chrome. 更新我遵循了@blesh的建议,我可以意识到它在Firefox中效果很好,但在Chrome中效果不佳。 I have written a sample in Punkler. 我已经在Punkler中编写了一个示例。
http://plnkr.co/edit/ESBWciLAKJosK2u6eZVD?p=preview http://plnkr.co/edit/ESBWciLAKJosK2u6eZVD?p=preview
Do you have any idea about what could it happen? 您有什么可能的想法吗?
I found it! 我找到了! In Chrome you must to specify the type of embedded content in an object tag. 在Chrome中,您必须在对象标签中指定嵌入内容的类型。
<div ng-controller="MainCtrl">
<div><h2>Example</h2></div>
<div id="attachments-section">
<tabs>
<pane ng-repeat="attachment in attachments" heading="{{attachment.title}}" active="attachment.active">
<div style="height: {{objHeight}}; overflow-y: hidden;">
<object type='application/pdf' width='100%', height='100%', data='{{attachment.filename}}'></object>
</div>
</pane>
</tabs>
</div>
</div>
Now this code in punkler works in any browser: http://plnkr.co/edit/ESBWciLAKJosK2u6eZVD 现在,punkler中的此代码可在任何浏览器中使用: http ://plnkr.co/edit/ESBWciLAKJosK2u6eZVD
Thanks for your help. 谢谢你的帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.