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

Commit

Permalink
feat(carousel): expose carousel controller via controllerAs
Browse files Browse the repository at this point in the history
- Expose the carousel controller in the component via `controllerAs`

Closes #4131
  • Loading branch information
wesleycho committed Aug 7, 2015
1 parent 8936885 commit bfec07e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
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');
}));
});
});

0 comments on commit bfec07e

Please sign in to comment.