Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit 17d6c3b

Browse files
committed
fix(carousel): make slide 'active' binding optional
1 parent 5f895c1 commit 17d6c3b

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/carousel/carousel.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,21 @@ angular.module('ui.bootstrap.carousel', ['ui.bootstrap.transition'])
189189
replace: true,
190190
templateUrl: 'template/carousel/slide.html',
191191
scope: {
192-
active: '='
193192
},
194193
link: function (scope, element, attrs, carouselCtrl) {
194+
//Set up optional 'active' = binding
195+
scope.active = false; // default value
196+
if (attrs.active) {
197+
var getActive = $parse(attrs.active);
198+
var setActive = getActive.assign;
199+
scope.$parent.$watch(getActive, function updateActive(value) {
200+
scope.active = !!value;
201+
});
202+
scope.$watch(getActive, function(value) {
203+
setActive(scope.$parent, !!value);
204+
});
205+
}
206+
195207
carouselCtrl.addSlide(scope, element);
196208
//when the scope is destroyed then remove the slide from the current slides array
197209
scope.$on('$destroy', function() {

0 commit comments

Comments
 (0)