Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit 049f052

Browse files
author
Nick Litwin
committed
Use arrow function
1 parent 1f3e085 commit 049f052

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

app/directives/tc-tabs/tc-tabs.directive.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ import angular from 'angular'
1313
scope: {},
1414
controller: ['$log', '$location', '$scope', function($log, $location, $scope, $element) {
1515
$log = $log.getInstance('TcTabSetController')
16-
var tabCtrl = this
1716
this.tabs = []
17+
1818
this.addTab = function addTab(tab) {
1919
this.tabs.push(tab)
20+
2021
if (!angular.isDefined($location.search().tab) && this.tabs.length === 1) {
2122
tab.active = true
2223
} else if ($location.search().tab === tab.heading) {
@@ -26,6 +27,7 @@ import angular from 'angular'
2627

2728
this.select = function(selectedTab) {
2829
var select = false
30+
2931
angular.forEach(this.tabs, function(tab) {
3032
if (tab.active && tab.heading !== selectedTab.heading) {
3133
tab.active = false
@@ -34,6 +36,7 @@ import angular from 'angular'
3436
select = true
3537
}
3638
})
39+
3740
if (select === false && this.tabs.length > 0) {
3841
this.tabs[0].active = true
3942
}
@@ -45,14 +48,14 @@ import angular from 'angular'
4548
}
4649
}
4750

48-
$scope.$on( '$locationChangeSuccess', function() {
51+
$scope.$on('$locationChangeSuccess', () => {
4952
var tab
5053
if (angular.isDefined($location.search().tab)) {
5154
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})
5659
}
5760
})
5861
}],

0 commit comments

Comments
 (0)