Skip to content

Commit 8190c50

Browse files
committed
fix(tabs): use interpolation for type attribute
Closes angular-ui#1409 BREAKING CHANGE: Use interpolation for type attribute. Before: <tabset type="'pills'" ...></tabset > or <tabset type="navtype" ...></tabset> After: <tabset type="pills" ...></tabset> or <tabset type="{{navtype}}" ...></tabset>
1 parent b87959a commit 8190c50

File tree

5 files changed

+12
-14
lines changed

5 files changed

+12
-14
lines changed

src/tabs/docs/demo.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
<hr />
2626

27-
<tabset vertical="true" type="navType">
27+
<tabset vertical="true" type="pills">
2828
<tab heading="Vertical 1">Vertical content 1</tab>
2929
<tab heading="Vertical 2">Vertical content 2</tab>
3030
</tabset>

src/tabs/docs/demo.js

-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,4 @@ var TabsDemoCtrl = function ($scope) {
99
alert("You've selected the alert tab!");
1010
});
1111
};
12-
13-
$scope.navType = 'pills';
1412
};

src/tabs/tabs.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@
99

1010
angular.module('ui.bootstrap.tabs', [])
1111

12-
.controller('TabsetController', ['$scope', function TabsetCtrl($scope) {
12+
.controller('TabsetController', ['$scope', '$attrs', function TabsetCtrl($scope, $attrs) {
1313
var ctrl = this,
1414
tabs = ctrl.tabs = $scope.tabs = [];
15+
16+
$scope.vertical = angular.isDefined($attrs.vertical) ? $scope.$parent.$eval($attrs.vertical) : false;
17+
$scope.justified = angular.isDefined($attrs.justified) ? $scope.$parent.$eval($attrs.justified) : false;
1518

1619
ctrl.select = function(tab) {
1720
angular.forEach(tabs, function(tab) {
@@ -74,14 +77,11 @@ angular.module('ui.bootstrap.tabs', [])
7477
restrict: 'EA',
7578
transclude: true,
7679
replace: true,
77-
scope: {},
80+
scope: {
81+
type: '@'
82+
},
7883
controller: 'TabsetController',
79-
templateUrl: 'template/tabs/tabset.html',
80-
link: function(scope, element, attrs) {
81-
scope.vertical = angular.isDefined(attrs.vertical) ? scope.$parent.$eval(attrs.vertical) : false;
82-
scope.justified = angular.isDefined(attrs.justified) ? scope.$parent.$eval(attrs.justified) : false;
83-
scope.type = angular.isDefined(attrs.type) ? scope.$parent.$eval(attrs.type) : 'tabs';
84-
}
84+
templateUrl: 'template/tabs/tabset.html'
8585
};
8686
})
8787

src/tabs/test/tabs.spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ describe('tabs', function() {
353353
beforeEach(inject(function($controller, $rootScope) {
354354
scope = $rootScope;
355355
//instantiate the controller stand-alone, without the directive
356-
ctrl = $controller('TabsetController', {$scope: scope, $element: null});
356+
ctrl = $controller('TabsetController', {$scope: scope, $attrs: {}, $element: null});
357357
}));
358358

359359

@@ -564,7 +564,7 @@ describe('tabs', function() {
564564
scope = $rootScope.$new();
565565
scope.navType = 'pills';
566566

567-
elm = $compile('<tabset type="navType"></tabset>')(scope);
567+
elm = $compile('<tabset type="{{navType}}"></tabset>')(scope);
568568
scope.$apply();
569569
}));
570570

template/tabs/tabset.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
<div class="tabbable">
3-
<ul class="nav {{type && 'nav-' + type}}" ng-class="{'nav-stacked': vertical, 'nav-justified': justified}" ng-transclude></ul>
3+
<ul class="nav nav-{{type || 'tabs'}}" ng-class="{'nav-stacked': vertical, 'nav-justified': justified}" ng-transclude></ul>
44
<div class="tab-content">
55
<div class="tab-pane"
66
ng-repeat="tab in tabs"

0 commit comments

Comments
 (0)