diff --git a/src/tabs/docs/readme.md b/src/tabs/docs/readme.md
index 0bdbfeb9ed..e7239a971c 100644
--- a/src/tabs/docs/readme.md
+++ b/src/tabs/docs/readme.md
@@ -5,7 +5,7 @@ AngularJS version of the tabs directive.
* `active`
_(Default: `Index of first tab`)_ -
- Active index of tab. Setting this to an existing tab index will make that tab active.
+ Active index of tab. Setting this to an existing tab index will make that tab active. Can be a number or string.
* `justified`
$
diff --git a/src/tabs/tabs.js b/src/tabs/tabs.js
index adf3c5c7a6..58000a1a68 100644
--- a/src/tabs/tabs.js
+++ b/src/tabs/tabs.js
@@ -73,7 +73,7 @@ angular.module('ui.bootstrap.tabs', [])
};
$scope.$watch('tabset.active', function(val) {
- if (angular.isNumber(val) && val !== oldIndex) {
+ if ((angular.isNumber(val) || angular.isString(val)) && val !== oldIndex) {
ctrl.select(findTabIndex(val));
}
});
@@ -85,7 +85,7 @@ angular.module('ui.bootstrap.tabs', [])
function findTabIndex(index) {
for (var i = 0; i < ctrl.tabs.length; i++) {
- if (ctrl.tabs[i].index === index) {
+ if (ctrl.tabs[i].index === +index) {
return i;
}
}
diff --git a/src/tabs/test/tabs.spec.js b/src/tabs/test/tabs.spec.js
index f2e7642e11..b6774df12b 100644
--- a/src/tabs/test/tabs.spec.js
+++ b/src/tabs/test/tabs.spec.js
@@ -168,6 +168,16 @@ describe('tabs', function() {
expect(titles().length).toBe(scope.tabs.length);
expectTabActive(scope.tabs[2]);
});
+
+ it("should watch active state", function() {
+ var controller = elm.controller('uibTabset');
+ spyOn(controller, "select");
+ expect(titles().length).toBe(scope.tabs.length);
+ expectTabActive(scope.tabs[2]);
+ scope.active = "7";
+ scope.$apply();
+ expect(controller.select).toHaveBeenCalledWith(3);
+ });
});
describe('without active binding and index attributes', function() {