@@ -13,10 +13,11 @@ import angular from 'angular'
13
13
scope : { } ,
14
14
controller : [ '$log' , '$location' , '$scope' , function ( $log , $location , $scope , $element ) {
15
15
$log = $log . getInstance ( 'TcTabSetController' )
16
- var tabCtrl = this
17
16
this . tabs = [ ]
17
+
18
18
this . addTab = function addTab ( tab ) {
19
19
this . tabs . push ( tab )
20
+
20
21
if ( ! angular . isDefined ( $location . search ( ) . tab ) && this . tabs . length === 1 ) {
21
22
tab . active = true
22
23
} else if ( $location . search ( ) . tab === tab . heading ) {
@@ -26,6 +27,7 @@ import angular from 'angular'
26
27
27
28
this . select = function ( selectedTab ) {
28
29
var select = false
30
+
29
31
angular . forEach ( this . tabs , function ( tab ) {
30
32
if ( tab . active && tab . heading !== selectedTab . heading ) {
31
33
tab . active = false
@@ -34,6 +36,7 @@ import angular from 'angular'
34
36
select = true
35
37
}
36
38
} )
39
+
37
40
if ( select === false && this . tabs . length > 0 ) {
38
41
this . tabs [ 0 ] . active = true
39
42
}
@@ -45,14 +48,14 @@ import angular from 'angular'
45
48
}
46
49
}
47
50
48
- $scope . $on ( '$locationChangeSuccess' , function ( ) {
51
+ $scope . $on ( '$locationChangeSuccess' , ( ) => {
49
52
var tab
50
53
if ( angular . isDefined ( $location . search ( ) . tab ) ) {
51
54
tab = $location . search ( ) . tab
52
- tabCtrl . select ( { 'heading' : tab } )
53
- } else if ( tabCtrl . tabs . length > 0 ) {
54
- tab = tabCtrl . tabs [ 0 ] . heading
55
- tabCtrl . select ( { 'heading' : tab } )
55
+ this . select ( { 'heading' : tab } )
56
+ } else if ( this . tabs . length > 0 ) {
57
+ tab = this . tabs [ 0 ] . heading
58
+ this . select ( { 'heading' : tab } )
56
59
}
57
60
} )
58
61
} ] ,
0 commit comments