I have been experimenting with the tabs feature of AngularUI Bootstrap by creating tabs dynamically.
<div ng-controller="TabsDemoCtrl">
<uib-tabset active="activeForm">
<uib-tab index="$index" ng-repeat="tab in tabs" >
<uib-tab-heading>{{tab.title}}</uib-tab-heading>
{{tab.content}}
</uib-tab>
</uib-tabset>
Although I am setting an active tab in the controller, when the tabs array is modified, the UI Tabs update but the active tab remains unchanged.
angular.module('ui.bootstrap.demo', ['ngAnimate', 'ngSanitize', 'ui.bootstrap']);
angular.module('ui.bootstrap.demo').controller('TabsDemoCtrl', function ($scope, $window) {
$scope.tabs = [
{ title:'Dynamic Title 1', content:'Dynamic content 1' },
{ title:'Dynamic Title 2', content:'Dynamic content 2' },
{ title:'Dynamic Title 3', content:'Dynamic content 3' },
{ title:'Dynamic Title 4', content:'Dynamic content 4' }
];
$scope.changeTabs = function(){
$scope.tabs = [
{ title:'Dynamic Title 5', content:'Dynamic content 5' },
{ title:'Dynamic Title 6', content:'Dynamic content 6' }
];
$scope.activeForm = 0; //Not working, how can I select tab dynamically?
};
$scope.model = {
name: 'Tabs'
};
});
Any insights on what could be causing this issue?
Check out the Plunker example here: https://plnkr.co/edit/Ow7Cd1eidCgaLNOhX1Vl
Thank you for your help. Paul