diff --git a/src/carousel/carousel.js b/src/carousel/carousel.js index cbbc62cedf..1b9c8b2fae 100644 --- a/src/carousel/carousel.js +++ b/src/carousel/carousel.js @@ -74,7 +74,7 @@ angular.module('ui.bootstrap.carousel', []) return angular.isDefined(slide.index) ? +slide.index : slides.indexOf(slide); }; - $scope.next = function() { + self.next = $scope.next = function() { var newIndex = (self.getCurrentIndex() + 1) % slides.length; if (newIndex === 0 && $scope.noWrap()) { @@ -85,7 +85,7 @@ angular.module('ui.bootstrap.carousel', []) return self.select(getSlideByIndex(newIndex), 'next'); }; - $scope.prev = function() { + self.prev = $scope.prev = function() { var newIndex = self.getCurrentIndex() - 1 < 0 ? slides.length - 1 : self.getCurrentIndex() - 1; if ($scope.noWrap() && newIndex === slides.length - 1) { diff --git a/src/carousel/test/carousel.spec.js b/src/carousel/test/carousel.spec.js index 274519e569..5323dd5a93 100644 --- a/src/carousel/test/carousel.spec.js +++ b/src/carousel/test/carousel.spec.js @@ -436,6 +436,14 @@ describe('carousel', function() { } }); + it('should expose .next()', function() { + expect(ctrl.next).toEqual(scope.next); + }); + + it('should expose .prev()', function() { + expect(ctrl.prev).toEqual(scope.prev); + }); + describe('addSlide', function() { it('should set first slide to active = true and the rest to false', function() { angular.forEach(ctrl.slides, function(slide, i) {