我正在尝试动态设置 uib-tabs。我的意思是我已经用 html 编写了所有代码,并且只动态获取索引来查看代码。我在这里简化了示例。我将 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>
提前致谢。
我不能将 ng-repeat 与标签一起使用,因为它们不同而且我的 HTML 文件太大