Skip to content

Commit

Permalink
fix(carousel): make slide 'active' binding optional
Browse files Browse the repository at this point in the history
  • Loading branch information
ajoslin committed Jun 22, 2013
1 parent 5f895c1 commit 17d6c3b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/carousel/carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,21 @@ angular.module('ui.bootstrap.carousel', ['ui.bootstrap.transition'])
replace: true,
templateUrl: 'template/carousel/slide.html',
scope: {
active: '='
},
link: function (scope, element, attrs, carouselCtrl) {
//Set up optional 'active' = binding
scope.active = false; // default value
if (attrs.active) {
var getActive = $parse(attrs.active);
var setActive = getActive.assign;
scope.$parent.$watch(getActive, function updateActive(value) {
scope.active = !!value;
});
scope.$watch(getActive, function(value) {
setActive(scope.$parent, !!value);
});
}

carouselCtrl.addSlide(scope, element);
//when the scope is destroyed then remove the slide from the current slides array
scope.$on('$destroy', function() {
Expand Down

0 comments on commit 17d6c3b

Please sign in to comment.