Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit a5cac90

Browse files
Sergii Stotskyiwesleycho
Sergii Stotskyi
authored andcommitted
feat(tabs): add controllerAs support
Closes #5019 Closes #5020
1 parent fd88dcb commit a5cac90

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

Diff for: src/tabs/tabs.js

+1
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ angular.module('ui.bootstrap.tabs', [])
201201
controller: function() {
202202
//Empty controller so other directives can require being 'under' a tab
203203
},
204+
controllerAs: 'tab',
204205
link: function(scope, elm, attrs, tabsetCtrl, transclude) {
205206
scope.$watch('active', function(active) {
206207
if (active) {

Diff for: src/tabs/test/tabs.spec.js

+27
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,33 @@ describe('tabs', function() {
192192
});
193193
});
194194

195+
describe('uib-tab', function() {
196+
var $compile, $templateCache;
197+
198+
beforeEach(inject(function($rootScope, _$compile_, _$templateCache_) {
199+
scope = $rootScope;
200+
$compile = _$compile_;
201+
$templateCache = _$templateCache_;
202+
}));
203+
204+
it('should expose the controller on the view', function() {
205+
$templateCache.put('uib/template/tabs/tab.html', '<li class="uib-tab">{{tab.text}}</li>');
206+
207+
elm = $compile('<uib-tabset><uib-tab heading="Tab"></uib-tab></uib-tabset>')(scope);
208+
scope.$digest();
209+
210+
var tab = titles().eq(0);
211+
var ctrl = tab.controller('uibTab');
212+
213+
expect(ctrl).toBeDefined();
214+
215+
ctrl.text = 'foo';
216+
scope.$digest();
217+
218+
expect(tab.text().trim()).toBe('foo');
219+
});
220+
});
221+
195222
describe('ng-repeat', function() {
196223
var $compile, $rootScope;
197224
beforeEach(inject(function(_$compile_, _$rootScope_) {

0 commit comments

Comments
 (0)