diff --git a/src/tabs/tabs.js b/src/tabs/tabs.js
index d5b9ed12ae..223bb9722f 100644
--- a/src/tabs/tabs.js
+++ b/src/tabs/tabs.js
@@ -77,12 +77,19 @@ function TabsetCtrl($scope, $element) {
restrict: 'EA',
transclude: true,
replace: true,
+ require: '^tabset',
scope: {},
controller: 'TabsetController',
templateUrl: 'template/tabs/tabset.html',
- link: function(scope, element, attrs) {
- scope.vertical = angular.isDefined(attrs.vertical) ? scope.$eval(attrs.vertical) : false;
- scope.type = angular.isDefined(attrs.type) ? scope.$parent.$eval(attrs.type) : 'tabs';
+ compile: function(elm, attrs, transclude) {
+ return function(scope, element, attrs, tabsetCtrl) {
+ scope.vertical = angular.isDefined(attrs.vertical) ? scope.$eval(attrs.vertical) : false;
+ scope.type = angular.isDefined(attrs.type) ? scope.$parent.$eval(attrs.type) : 'tabs';
+ scope.direction = angular.isDefined(attrs.direction) ? scope.$parent.$eval(attrs.direction) : 'top';
+ scope.tabsAbove = (scope.direction != 'below');
+ tabsetCtrl.$scope = scope;
+ tabsetCtrl.$transcludeFn = transclude;
+ };
}
};
})
@@ -280,5 +287,24 @@ function($parse, $http, $templateCache, $compile) {
}
}])
+.directive('tabsetTitles', function($http) {
+ return {
+ restrict: 'A',
+ require: '^tabset',
+ templateUrl: 'template/tabs/tabset-titles.html',
+ replace: true,
+ link: function(scope, elm, attrs, tabsetCtrl) {
+ if (!scope.$eval(attrs.tabsetTitles)) {
+ elm.remove();
+ } else {
+ //now that tabs location has been decided, transclude the tab titles in
+ tabsetCtrl.$transcludeFn(tabsetCtrl.$scope.$parent, function(node) {
+ elm.append(node);
+ });
+ }
+ }
+ };
+})
+
;
diff --git a/src/tabs/test/tabsSpec.js b/src/tabs/test/tabsSpec.js
index d0f0d9d842..18651a7276 100644
--- a/src/tabs/test/tabsSpec.js
+++ b/src/tabs/test/tabsSpec.js
@@ -1,5 +1,5 @@
describe('tabs', function() {
- beforeEach(module('ui.bootstrap.tabs', 'template/tabs/tabset.html', 'template/tabs/tab.html'));
+ beforeEach(module('ui.bootstrap.tabs', 'template/tabs/tabset.html', 'template/tabs/tab.html', 'template/tabs/tabset-titles.html'));
var elm, scope;
function titles() {
@@ -483,6 +483,56 @@ describe('tabs', function() {
});
});
+ describe('direction', function() {
+ it('should not have `tab-left`, `tab-right` nor `tabs-below` classes if the direction is undefined', inject(function($compile, $rootScope) {
+ scope = $rootScope.$new();
+ scope.direction = undefined;
+
+ elm = $compile('