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

Commit bfec07e

Browse files
committed
feat(carousel): expose carousel controller via controllerAs
- Expose the carousel controller in the component via `controllerAs` Closes #4131
1 parent 8936885 commit bfec07e

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/carousel/carousel.js

+1
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ angular.module('ui.bootstrap.carousel', [])
249249
transclude: true,
250250
replace: true,
251251
controller: 'CarouselController',
252+
controllerAs: 'carousel',
252253
require: 'carousel',
253254
templateUrl: 'template/carousel/carousel.html',
254255
scope: {

src/carousel/test/carousel.spec.js

+17
Original file line numberDiff line numberDiff line change
@@ -457,5 +457,22 @@ describe('carousel', function() {
457457
expect(scope.next.calls.count()).toBe(1);
458458
});
459459
});
460+
461+
it('should be exposed in the template', inject(function($templateCache) {
462+
$templateCache.put('template/carousel/carousel.html', '<div>{{carousel.text}}</div>');
463+
464+
var scope = $rootScope.$new();
465+
var elm = $compile('<carousel interval="bar" no-transition="false" no-pause="true"></carousel>')(scope);
466+
$rootScope.$digest();
467+
468+
var ctrl = elm.controller('carousel');
469+
470+
expect(ctrl).toBeDefined();
471+
472+
ctrl.text = 'foo';
473+
$rootScope.$digest();
474+
475+
expect(elm.html()).toBe('foo');
476+
}));
460477
});
461478
});

0 commit comments

Comments
 (0)