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

Commit

Permalink
feat(tabs): add controllerAs support
Browse files Browse the repository at this point in the history
Closes #5019
Closes #5020
Sergii Stotskyi authored and wesleycho committed Dec 7, 2015
1 parent fd88dcb commit a5cac90
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/tabs/tabs.js
Original file line number Diff line number Diff line change
@@ -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) {
27 changes: 27 additions & 0 deletions src/tabs/test/tabs.spec.js
Original file line number Diff line number Diff line change
@@ -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_) {

0 comments on commit a5cac90

Please sign in to comment.