From bfec07e45ec95b87d2d2fb5c2a2fe38ab8ab0643 Mon Sep 17 00:00:00 2001 From: Wesley Cho Date: Thu, 6 Aug 2015 22:17:37 -0700 Subject: [PATCH] feat(carousel): expose carousel controller via `controllerAs` - Expose the carousel controller in the component via `controllerAs` Closes #4131 --- src/carousel/carousel.js | 1 + src/carousel/test/carousel.spec.js | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/carousel/carousel.js b/src/carousel/carousel.js index 5097f13c82..86aae0f4d4 100644 --- a/src/carousel/carousel.js +++ b/src/carousel/carousel.js @@ -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: { diff --git a/src/carousel/test/carousel.spec.js b/src/carousel/test/carousel.spec.js index 093afd6d01..1e4be5cfee 100644 --- a/src/carousel/test/carousel.spec.js +++ b/src/carousel/test/carousel.spec.js @@ -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', '
{{carousel.text}}
'); + + var scope = $rootScope.$new(); + var elm = $compile('')(scope); + $rootScope.$digest(); + + var ctrl = elm.controller('carousel'); + + expect(ctrl).toBeDefined(); + + ctrl.text = 'foo'; + $rootScope.$digest(); + + expect(elm.html()).toBe('foo'); + })); }); });