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

fix(tabs): added controllerAs for tab controller #5020

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/tabs/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ angular.module('ui.bootstrap.tabs', [])
controller: function() {
//Empty controller so other directives can require being 'under' a tab
},
controllerAs: 'tab',
link: function(scope, elm, attrs, tabsetCtrl, transclude) {
scope.$watch('active', function(active) {
if (active) {
Expand Down
27 changes: 27 additions & 0 deletions src/tabs/test/tabs.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,33 @@ describe('tabs', function() {
});
});

describe('uib-tab', function() {
var $compile, $templateCache;

beforeEach(inject(function($rootScope, _$compile_, _$templateCache_) {
scope = $rootScope;
$compile = _$compile_;
$templateCache = _$templateCache_;
}));

it('should expose the controller on the view', function() {
$templateCache.put('uib/template/tabs/tab.html', '<li class="uib-tab">{{tab.text}}</li>');

elm = $compile('<uib-tabset><uib-tab heading="Tab"></uib-tab></uib-tabset>')(scope);
scope.$digest();

var tab = titles().eq(0);
var ctrl = tab.controller('uibTab');

expect(ctrl).toBeDefined();

ctrl.text = 'foo';
scope.$digest();

expect(tab.text().trim()).toBe('foo');
});
});

describe('ng-repeat', function() {
var $compile, $rootScope;
beforeEach(inject(function(_$compile_, _$rootScope_) {
Expand Down