This repository was archived by the owner on May 29, 2019. It is now read-only.
File tree 3 files changed +13
-3
lines changed
3 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ AngularJS version of the tabs directive.
5
5
* ` active `
6
6
<i class =" glyphicon glyphicon-eye-open " ></i >
7
7
_ (Default: ` Index of first tab ` )_ -
8
- Active index of tab. Setting this to an existing tab index will make that tab active.
8
+ Active index of tab. Setting this to an existing tab index will make that tab active. Can be a number or string.
9
9
10
10
* ` justified `
11
11
<small class =" badge " >$</small >
Original file line number Diff line number Diff line change @@ -73,7 +73,7 @@ angular.module('ui.bootstrap.tabs', [])
73
73
} ;
74
74
75
75
$scope . $watch ( 'tabset.active' , function ( val ) {
76
- if ( angular . isNumber ( val ) && val !== oldIndex ) {
76
+ if ( ( angular . isNumber ( val ) || angular . isString ( val ) ) && val !== oldIndex ) {
77
77
ctrl . select ( findTabIndex ( val ) ) ;
78
78
}
79
79
} ) ;
@@ -85,7 +85,7 @@ angular.module('ui.bootstrap.tabs', [])
85
85
86
86
function findTabIndex ( index ) {
87
87
for ( var i = 0 ; i < ctrl . tabs . length ; i ++ ) {
88
- if ( ctrl . tabs [ i ] . index === index ) {
88
+ if ( ctrl . tabs [ i ] . index === + index ) {
89
89
return i ;
90
90
}
91
91
}
Original file line number Diff line number Diff line change @@ -168,6 +168,16 @@ describe('tabs', function() {
168
168
expect ( titles ( ) . length ) . toBe ( scope . tabs . length ) ;
169
169
expectTabActive ( scope . tabs [ 2 ] ) ;
170
170
} ) ;
171
+
172
+ it ( "should watch active state" , function ( ) {
173
+ var controller = elm . controller ( 'uibTabset' ) ;
174
+ spyOn ( controller , "select" ) ;
175
+ expect ( titles ( ) . length ) . toBe ( scope . tabs . length ) ;
176
+ expectTabActive ( scope . tabs [ 2 ] ) ;
177
+ scope . active = "7" ;
178
+ scope . $apply ( ) ;
179
+ expect ( controller . select ) . toHaveBeenCalledWith ( 3 ) ;
180
+ } ) ;
171
181
} ) ;
172
182
173
183
describe ( 'without active binding and index attributes' , function ( ) {
You can’t perform that action at this time.
0 commit comments