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 next and prev on controller
Browse files Browse the repository at this point in the history
- Expose `prev` and `next` functions on the carousel controller

Closes #4851
Closes #4853
  • Loading branch information
jsdevel authored and wesleycho committed Nov 10, 2015
1 parent 26d3103 commit 9b80ee1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/carousel/carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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) {
Expand Down
8 changes: 8 additions & 0 deletions src/carousel/test/carousel.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 9b80ee1

Please sign in to comment.