Skip to content

Commit 00bbad1

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 161a996 commit 00bbad1

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

src/tabs/docs/demo.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
<hr />
2323

24-
<tabset vertical="true" type="navType">
24+
<tabset vertical="true" type="pills">
2525
<tab heading="Vertical 1">Vertical content 1</tab>
2626
<tab heading="Vertical 2">Vertical content 2</tab>
2727
</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

+9-6
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,16 @@
99

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

12-
.controller('TabsetController', ['$scope', function TabsetCtrl($scope) {
12+
.constant('tabsConfig', {
13+
type: 'tabs'
14+
})
15+
16+
.controller('TabsetController', ['$scope', '$attrs', '$interpolate', 'tabsConfig', function TabsetCtrl($scope, $attrs, $interpolate, tabsConfig) {
1317
var ctrl = this,
1418
tabs = ctrl.tabs = $scope.tabs = [];
19+
20+
$scope.vertical = angular.isDefined($attrs.vertical) ? $scope.$parent.$eval($attrs.vertical) : false;
21+
$scope.type = angular.isDefined($attrs.type) ? $interpolate($attrs.type)($scope.$parent) : tabsConfig.type;
1522

1623
ctrl.select = function(tab) {
1724
angular.forEach(tabs, function(tab) {
@@ -71,11 +78,7 @@ angular.module('ui.bootstrap.tabs', [])
7178
replace: true,
7279
scope: {},
7380
controller: 'TabsetController',
74-
templateUrl: 'template/tabs/tabset.html',
75-
link: function(scope, element, attrs) {
76-
scope.vertical = angular.isDefined(attrs.vertical) ? scope.$parent.$eval(attrs.vertical) : false;
77-
scope.type = angular.isDefined(attrs.type) ? scope.$parent.$eval(attrs.type) : 'tabs';
78-
}
81+
templateUrl: 'template/tabs/tabset.html'
7982
};
8083
})
8184

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

@@ -551,7 +551,7 @@ describe('tabs', function() {
551551
scope = $rootScope.$new();
552552
scope.navType = 'pills';
553553

554-
elm = $compile('<tabset type="navType"></tabset>')(scope);
554+
elm = $compile('<tabset type="{{navType}}"></tabset>')(scope);
555555
scope.$apply();
556556
}));
557557

0 commit comments

Comments
 (0)