简体   繁体   English

uib-tabset动态索引不起作用

[英]uib-tabset dynamic index not working

I am trying to set uib-tabs dynamically. 我正在尝试动态设置uib选项卡。 I mean I have written all the codes in html and only taking index dynamically see the code. 我的意思是我已经用html编写了所有代码,只有动态获取索引才能看到代码。 I have simplified the example here. 我在这里简化了示例。 I gave index="1" to very first tab but it's not working as required. 我将index =“ 1”分配给了第一个选项卡,但是它不能按要求工作。

 <link href="https://netdna.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-animate.js"></script> <script src="https://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-2.0.0.js"></script> <div ng-app="uib-tabs.demo" ng-controller="TabsDemoCtrl"> <!--I have given index 1 to Static tab still it's at index 0. actually in my code I am calling a function from index which returns the index somethiing like this <uib-tab index="findMyIndex('static')" heading="Static title">Static content</uib-tab>--> <uib-tabset active="active"> <uib-tab index="1" heading="Static title">Static content</uib-tab> <uib-tab index="0" 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> </uib-tabset> </div> <script> angular.module('uib-tabs.demo', ['ngAnimate', 'ui.bootstrap']) .controller('TabsDemoCtrl', function ($scope, $window) { $scope.tabs = [ { title:'Dynamic Title 1', content:'Dynamic content 1' }, { title:'Dynamic Title 2', content:'Dynamic content 2', disabled: true } ]; $scope.alertMe = function() { setTimeout(function() { $window.alert('You\\'ve selected the alert tab!'); }); }; $scope.model = { name: 'Tabs' }; }); </script> 

Thanks in Advance. 提前致谢。

I can't use ng-repeat with tabs as they are different and my HTML file is too large 我不能将ng-repeat与选项卡一起使用,因为它们不同并且HTML文件太大

You can use $index to set the tabs index dynamically and ng-repeat to generate the tabsets. 您可以使用$index动态设置标签索引,并使用ng-repeat生成标签集。

<uib-tabset active="active">
  <uib-tab  index="$index" ng-repeat="tab in tabs" >
    <uib-tab-heading>{{tab.title}}</uib-tab-heading>
    {{tab.content}}
  </uib-tab>
</uib-tabset>

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

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