IonicModule .directive('ionTabNav', ['$ionicNgClick', function($ionicNgClick) { return { restrict: 'E', replace: true, require: ['^ionTabs', '^ionTab'], template: '' + '{{badge}}' + '' + '' + '' + '', scope: { title: '@', icon: '@', iconOn: '@', iconOff: '@', badge: '=', badgeStyle: '@' }, compile: function(element, attr, transclude) { return function link($scope, $element, $attrs, ctrls) { var tabsCtrl = ctrls[0], tabCtrl = ctrls[1]; //Remove title attribute so browser-tooltip does not apear $element[0].removeAttribute('title'); $scope.selectTab = function(e) { e.preventDefault(); tabsCtrl.select(tabCtrl.$scope, true); }; if (!$attrs.ngClick) { $ionicNgClick($scope, $element, 'selectTab($event)'); } $scope.getIconOn = function() { return $scope.iconOn || $scope.icon; }; $scope.getIconOff = function() { return $scope.iconOff || $scope.icon; }; $scope.isTabActive = function() { return tabsCtrl.selectedTab() === tabCtrl.$scope; }; }; } }; }]);