diff --git a/src/accordion/accordion.js b/src/accordion/accordion.js index b705701c97..4450b07b79 100644 --- a/src/accordion/accordion.js +++ b/src/accordion/accordion.js @@ -45,8 +45,9 @@ angular.module('ui.bootstrap.accordion', ['ui.bootstrap.collapse']) // and adds an accordion CSS class to itself element. .directive('accordion', function () { return { - restrict:'EA', - controller:'AccordionController', + restrict: 'EA', + controller: 'AccordionController', + controllerAs: 'accordion', transclude: true, replace: false, templateUrl: function(element, attrs) { diff --git a/src/accordion/test/accordion.spec.js b/src/accordion/test/accordion.spec.js index 0436655da8..decedaf98b 100644 --- a/src/accordion/test/accordion.spec.js +++ b/src/accordion/test/accordion.spec.js @@ -103,20 +103,36 @@ describe('accordion', function () { }); describe('accordion', function () { - var scope, $compile, element; + var scope, $compile, $templateCache, element; - beforeEach(inject(function($rootScope, _$compile_) { + beforeEach(inject(function($rootScope, _$compile_, _$templateCache_) { scope = $rootScope; $compile = _$compile_; + $templateCache = _$templateCache_; })); - it('should allow custom templates', inject(function ($templateCache) { + it('should expose the controller on the view', function () { + $templateCache.put('template/accordion/accordion.html', '
{{accordion.text}}
'); + + element = $compile('foo'); + }); + + it('should allow custom templates', function () { $templateCache.put('foo/bar.html', '
baz
'); element = $compile('')(scope); scope.$digest(); expect(element.html()).toBe('
baz
'); - })); + }); }); describe('accordion-group', function () {