From 803191cb08051c959f7d660bb87bc0478f64418c Mon Sep 17 00:00:00 2001 From: Tom France Date: Mon, 18 Aug 2014 13:57:11 +0100 Subject: [PATCH] fix(tabs): don't select tabs on destroy Fixes #2155 Closes #2596 --- src/tabs/tabs.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/tabs/tabs.js b/src/tabs/tabs.js index e1b5ee8485..710959759a 100644 --- a/src/tabs/tabs.js +++ b/src/tabs/tabs.js @@ -37,14 +37,19 @@ angular.module('ui.bootstrap.tabs', []) ctrl.removeTab = function removeTab(tab) { var index = tabs.indexOf(tab); - //Select a new tab if the tab to be removed is selected - if (tab.active && tabs.length > 1) { + //Select a new tab if the tab to be removed is selected and not destroyed + if (tab.active && tabs.length > 1 && !destroyed) { //If this is the last tab, select the previous tab. else, the next tab. var newActiveIndex = index == tabs.length - 1 ? index - 1 : index + 1; ctrl.select(tabs[newActiveIndex]); } tabs.splice(index, 1); }; + + var destroyed; + $scope.$on('$destroy', function() { + destroyed = true; + }); }]) /**