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

feat(carousel): expose carousel controller via controllerAs #4131

Closed
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/carousel/carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ angular.module('ui.bootstrap.carousel', [])
transclude: true,
replace: true,
controller: 'CarouselController',
controllerAs: 'carousel',
require: 'carousel',
templateUrl: 'template/carousel/carousel.html',
scope: {
Expand Down
17 changes: 17 additions & 0 deletions src/carousel/test/carousel.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,5 +457,22 @@ describe('carousel', function() {
expect(scope.next.calls.count()).toBe(1);
});
});

it('should be exposed in the template', inject(function($templateCache) {
$templateCache.put('template/carousel/carousel.html', '<div>{{carousel.text}}</div>');

var scope = $rootScope.$new();
var elm = $compile('<carousel interval="bar" no-transition="false" no-pause="true"></carousel>')(scope);
$rootScope.$digest();

var ctrl = elm.controller('carousel');

expect(ctrl).toBeDefined();

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

expect(elm.html()).toBe('foo');
}));
});
});