Skip to content

Commit 28e9959

Browse files
committed
fix(tabs): fixes an issue with #6292
fixes an issue with 6292 #6292
1 parent 9df3898 commit 28e9959

File tree

2 files changed

+9
-28
lines changed

2 files changed

+9
-28
lines changed

js/angular/directive/tabNav.js

+8-27
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ IonicModule
55
replace: true,
66
require: ['^ionTabs', '^ionTab'],
77
template:
8-
'<a ng-class="{\'has-badge\':badge, \'tab-hidden\':isHidden()}" ' +
8+
'<a ng-class="{\'has-badge\':badge, \'tab-hidden\':isHidden(), \'tab-item-active\': isTabActive()}" ' +
99
' ng-disabled="disabled()" class="tab-item">' +
1010
'<span class="badge {{badgeStyle}}" ng-if="badge">{{badge}}</span>' +
11-
'<i class="icon"></i>' +
11+
'<i class="icon {{getIcon()}}" ng-if="getIcon()"></i>' +
1212
'<span class="tab-title" ng-bind-html="title"></span>' +
1313
'</a>',
1414
scope: {
@@ -57,35 +57,16 @@ IonicModule
5757
return tabsCtrl.selectedTab() === tabCtrl.$scope;
5858
};
5959

60-
$scope.$watch("icon", function() {
61-
styleTab();
62-
});
63-
64-
$scope.$watch("iconOff", function() {
65-
styleTab();
66-
});
67-
68-
$scope.$watch("iconOn", function() {
69-
styleTab();
70-
});
71-
72-
function styleTab() {
73-
// check if tab if active
60+
$scope.getIcon = function() {
7461
if ( tabsCtrl.selectedTab() === tabCtrl.$scope ) {
75-
$element.addClass('tab-item-active');
76-
$element.find('i').removeClass($scope.getIconOff());
77-
$element.find('i').addClass($scope.getIconOn());
62+
// active
63+
return $scope.iconOn || $scope.icon;
7864
}
7965
else {
80-
$element.removeClass('tab-item-active');
81-
$element.find('i').removeClass($scope.getIconOn());
82-
$element.find('i').addClass($scope.getIconOff());
66+
// inactive
67+
return $scope.iconOff || $scope.icon;
8368
}
84-
}
85-
86-
$scope.$on("tabSelected", styleTab);
87-
88-
styleTab();
69+
};
8970
}
9071
};
9172
}]);

test/html/tabs-starter.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ <h2>Welcome to Ionic</h2>
9393
<script id="templates/tabs.html" type="text/ng-template">
9494
<ion-tabs class="tabs-icon-top tabs-color-active-positive">
9595
<!-- Dashboard Tab -->
96-
<ion-tab title="Status" icon-off="ion-ios-pulse" icon-on="ion-ios-pulse-strong" href="#/tab/dash">
96+
<ion-tab title="Status" href="#/tab/dash">
9797
<ion-nav-view name="tab-dash"></ion-nav-view>
9898
</ion-tab>
9999

0 commit comments

Comments
 (0)