在 angular bootstrap 中设置初始静态选项卡 [英] Setting the initial static tab in angular bootstrap
问题描述
我似乎无法在角度引导标签集中设置初始标签.它始终将最左侧的选项卡设置为活动状态.
I don't seem to be able to set the inital tab in an angular bootstrap tabset. It always sets the left most tab to active.
给定 html:
<tabset>
<tab heading="Static 1" active="data.static1">Static content</tab>
<tab heading="Static 2" active="data.static2">Static content</tab>
</tabset>
和js:
angular.module('plunker', ['ui.bootstrap']);
var TabsDemoCtrl = function ($scope) {
$scope.data = {static1: false, static2: true}
};
查看Plunker
2013 年 8 月 6 日更新:现已修复上游,请参阅 github 问题.
Update 6 Aug 2013: Now fixed upstream see the github issue.
推荐答案
似乎(静态)选项卡会在指令运行时覆盖传递给 active 的任何内容.我认为这是一个错误.快速而肮脏,您可以使用具有 0 秒延迟的超时来设置活动状态.至少在 plunkr 中,这不会导致任何闪烁.在您的控制器中:
It seems like (static) tabs overwrite whatever is passed to active when the directive is run. I assume it's a bug. Quick and dirty, you can use a timeout with 0 seconds delay to set the active state. At least in the plunkr, this does not cause any flicker. In your controller:
$scope.data = {};
$timeout(function() {
$scope.data.static2 = true;
}, 0)
http://plnkr.co/edit/3KbdKh?p=preview
这篇关于在 angular bootstrap 中设置初始静态选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!